
Python Functions and Parameters Quiz
Authored by ruth sutton
Other
12th Grade
Used 2+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What keyword is used to define a function in Python?
function
def
define
lambda
Answer explanation
In Python, the keyword 'def' is used to define a function. The other options, 'function', 'define', and 'lambda', are not valid keywords for this purpose. Therefore, 'def' is the correct choice.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code? def my_function(): return 5 print(my_function())
5
None
my_function()
Error
Answer explanation
The function my_function() returns the value 5. When print(my_function()) is called, it outputs the return value of the function, which is 5. Therefore, the correct answer is 5.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is true for procedures in Python?
They always return a value
They are defined using def
They cannot take arguments
They are not supported in Python
Answer explanation
In Python, procedures (functions) are defined using the 'def' keyword. They can return a value, and they can also take arguments, making the statement 'They are defined using def' the only true option.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the following code output? def greet(name="User"): print(f"Hello, {name}") greet()
Hello, User
Hello, name
None
Error
Answer explanation
The function greet has a default parameter 'name' set to 'User'. When called without arguments, it uses this default value, resulting in the output 'Hello, User', which matches the correct answer choice.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is a parameter?
The name of a function
A value returned by the function
A variable defined in the function header
A keyword to end a function
Answer explanation
A parameter is a variable defined in the function header that allows you to pass information into the function. It is not the function's name, return value, or a keyword to end a function.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is an argument?
A placeholder for code
A variable defined inside the function
A value passed to a function when called
A condition for the function
Answer explanation
An argument is a value passed to a function when it is called. This allows the function to operate on different data inputs, making it flexible and reusable.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will the following code return? def add(a, b): return a + b print(add(2, 3))
2
3
5
None
Answer explanation
The function 'add' takes two arguments, 'a' and 'b', and returns their sum. When calling 'add(2, 3)', it computes 2 + 3, which equals 5. Therefore, the correct answer is 5.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
20 questions
Exprésate 2 capitulo 6-2 vocabulario
Quiz
•
9th - 12th Grade
15 questions
Harry Potter
Quiz
•
KG - Professional Dev...
20 questions
Quiz on Famous Personalities
Quiz
•
9th - 12th Grade
17 questions
Argentina
Quiz
•
1st - 12th Grade
20 questions
Les lieux en ville
Quiz
•
KG - University
17 questions
Chapter 16 8th Grade Science Putman
Quiz
•
6th - 12th Grade
22 questions
1-5呵護銀色好時光
Quiz
•
9th - 12th Grade
20 questions
PBNO Holiday Trivia
Quiz
•
12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
Discover more resources for Other
20 questions
-AR -ER -IR present tense
Quiz
•
10th - 12th Grade
12 questions
Add and Subtract Polynomials
Quiz
•
9th - 12th Grade
13 questions
Model Exponential Growth and Decay Scenarios
Quiz
•
9th - 12th Grade
27 questions
7.2.3 Quadrilateral Properties
Quiz
•
9th - 12th Grade
7 questions
Amoeba Sisters Dihybrid Cross Punnett Square
Interactive video
•
9th - 12th Grade
10 questions
The Holocaust: Historical Overview
Interactive video
•
9th - 12th Grade
10 questions
Key Features of Quadratic Functions
Interactive video
•
8th - 12th Grade
11 questions
Exponent Quotient Rules A1 U7
Quiz
•
9th - 12th Grade