Done
Welcome * * from Python for Everybody
1. Which Python keyword indicates the start of a function definition?
sweet
help
break
def
2. In Python, how do you indicate the end of the block of code that makes up the function?
You de-indent a line of code to the same indent level as the def keyword
You put a # character at the end of the last line of the function
You put the "END" keyword in column 7 of the line which is to be the last line of the
function
You add the matching curly brace that was used to start the function }
3. In Python what is the input() feature best described as?
The central processing unit
A user-defined function
A built-in function
A conditional statement
4. What does the following code print out?
def thing():
print('Hello')
print('There')
There
thing Hello There
Hello
def thing
https://www.py4e.com/mod/gift/?quiz=Py4Inf-04-Functions.txt&PHPSESSID=243212159745ec44089419ddc0093997 06/10/2025, 2 58 AM
Page 1 of 3
:
5. In the following Python code, which of the following is an "argument" to a function?
x = 'banana'
y = max(x)
print(y)
x and y
max
'banana'
print
6. What will the following Python code print out?
def func(x) :
print(x)
func(10)
func(20)
10 20
func func
x 10 x 20
x 20
7. Which line of the following Python program will never execute?
def stuff():
print('Hello')
return
print('World')
stuff()
return
print ('World')
def stuff():
stuff()
print('Hello')
https://www.py4e.com/mod/gift/?quiz=Py4Inf-04-Functions.txt&PHPSESSID=243212159745ec44089419ddc0093997 06/10/2025, 2 58 AM
Page 2 of 3
:
8. What will the following Python program print out?
def greet(lang):
if lang == 'es':
return 'Hola'
elif lang == 'fr':
return 'Bonjour'
else:
return 'Hello'
print(greet('fr'),'Michael')
def Hola Bonjour Hello Michael
Hola Michael
Hola Bonjour Hello Michael
Bonjour Michael
9. What is the most important benefit of writing your own functions?
To avoid having more than 10 lines of sequential code without an indent or de-indent
Following the rule that no function can have more than 10 statements in it
Avoiding writing the same non-trivial code more than once in your program
Following the rule that whenever a program is more than 10 lines you must use a function
Submit
https://www.py4e.com/mod/gift/?quiz=Py4Inf-04-Functions.txt&PHPSESSID=243212159745ec44089419ddc0093997 06/10/2025, 2 58 AM
Page 3 of 3
: