2 Chapter 4: Functions
d. Calling square with a non-numeric argument like ‘hello’ causes a TypeEr-
ror because the exponentiation operator (**) works only with numeric values.
4.2 Q2: Which of the following statements is false?
a. A function definition begins with the def keyword, followed by the function
name, a set of parentheses and a colon (:).
b. Like variable identifiers, by convention function names should begin with a
lowercase letter and in multiword names underscores should separate each
word.
c. The required parentheses in a function definition contain the function’s param-
eter list—a comma-separated list of parameters representing the data that the
function needs to perform its task.
d. The indented lines after the colon (:) are the function’s suite, which consists of
an optional docstring followed by the statements that perform the function’s task.
4.2 Q3: Which of the following statements is false?
a. The following return statement first terminates the function, then squares
number and gives the result back to the caller:
return number ** 2
b. Function calls can be embedded in expressions.
c. The following code calls square first, then print displays the result:
print(‘The square of 7 is’, square(7))
d. Executing a return statement without an expression terminates the function
and implicitly returns the value None to the caller. When there’s no return state-
ment in a function, it implicitly returns the value None after executing the last
statement in the function’s block.
4.2 Q4: Which of the following statements is false?
a. Variables can be defined in a function’s block.
b. A function’s parameters and variables are all local variables. They exist only
while the function is executing and can be used only in that function.
c. Trying to access a local variable outside its function’s block causes a NameEr-
ror, indicating that the variable is not defined.