wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Functions and Returns

Total questions: 14

Worksheet time: 12mins

Name
Class
Date
1.
What will print?
a)
nothing
b)
5
c)
6
d)
an error message
2.

What does the following code output?

a)

11, 9

b)

16, 16

c)

None, None

d)

225, 117

3.

Which of the following is the correct code to define a function?

a)

def area ( ):

b)

area ( )

c)

def area:

d)

def area ( )

4.
How do you correctly call this function
a)
def(1)
b)
x=square( )
c)
defSquare(4)
d)
x=square(5)
5.

Which keyword marks a spot in a function where the program flow will go back to the calling code?

a)

break

b)

return

c)

continue

d)

jump

6.

Which of the following statements correctly defines a function named "haunted" that takes a parameter named "apple"?

a)

haunted(apple)

b)

haunted

c)

def haunted(apple):

d)

apple

7.

Which of the following statements will successfully send the value "EEK" back from a function to the calling code?

a)

EEK

b)

return EEK

c)

back EEK

d)

#print(EEK)

8.

What should go under the line that says if right > .7?

(a)  

9.

What should go in the else statement?

(a)  

10.

What should go in the blank of the while statement?

a)

is_over_line()

b)

is_over_line

c)

is_over_line(reflectance.get_right)

d)

reflectance.get_right()

11.

  1. Create a function named your_mom with a parameter age



(a)  

12.

  1. When you use your function, you will want to take the age and subtract 21. Write what would be inside the function



(a)  

13.

  1. Call the function your_mom with the argument 56



(a)  

14.

what will happen in the console when you run this code:

print(your_mom(56))

(a)