Python Programming for Raspberry Pi, Sams Teach Yourself in 24 Hours

(singke) #1
3. You must define a function before you can use it in your Python script. True or false?

Answers


1. b. Parameters. The parameters help keep the function self-contained; all of the data required for
the function are passed as parameters from the main program.
2. False. You can use recursion to reference a function inside itself. However, there must be a
predefined endpoint in the function; otherwise, it will get stuck in an infinite loop.
3. True. If the Python interpreter sees a function in use in your code, it must have the definition in
memory to know how to process it. The Python interpreter can’t read ahead in the code to find
the function definition.
Free download pdf