Page 89 -
P. 89
sharing your code
Before your write new code, think BIF
When you come across a need that you think is generic, ask yourself if there’s
a built-in function (BIF) that can help. After all, iterating a fixed number of
times is something you’ll need to do all the time.
And remember: Python 3 includes over 70 BIFs, so there’s a lot of
functionality waiting to be discovered.
Use your pencil to draw a line matching each BIF to the correct description.
The first one is done for you. Once you have all your lines drawn, circle the
BIF you think you need to use in the next version of your function.
BIF What the BIF does
list() Creates a numbered list of paired-data, starting
from 0.
range() Returns the unique identification for a Python
data object.
enumerate() A factory function that creates a new, empty list.
int() Returns the next item from a iterable data
structure such as a list.
id() Returns an iterator that generates numbers in a
specified range on demand and as needed.
next() Converts a string or another number to an
integer (if possible).
you are here 4 53