WorksheetsQuiz 4
Total questions: 10
Worksheet time: 5hrs 0mins
Name
Class
Date
1.
Which keyword is used to define a function in Python?
a)
func
b)
function
c)
def
d)
define
2.
What is the correct way to call this function?
def greet():
print("Hello!")
a)
call greet()
b)
greet()
c)
print greet()
d)
def greet()
3.
What does the return keyword do in a function?
a)
It exits the program
b)
It prints a value
c)
It sends a value back to the caller
d)
It pauses the function
4.
a)
23
b)
5
c)
a + b
d)
Error
5.
a)
test
b)
Done
c)
None
d)
Error
6.
Which of the following statements about function parameters is correct?
a)
Functions never need parameters
b)
Parameters are values returned by a function
c)
Parameters allow functions to receive input values
d)
Parameters are only used with the print() function
7.
Which of the following is a parameter in this function definition? def double(x): return x * 2
a)
def
b)
double
c)
x
d)
None
8.
Which of the following best describes a function?
a)
A block of code that runs only once
b)
A tool for printing messages
c)
A block of reusable code
d)
A variable that stores input
9.
Write a function called multiply(a, b) that returns the result of multiplying two numbers.
Then, ask the user to enter two numbers, call the function, and print the result.
4 lines
10.
Write a program with a function get_grade(score) that:
@ Returns "Pass" if the score is ≥ 50
@ Returns "Fail" otherwise
Ask the user for a score and display the result.
4 lines
100 %
