
Python Functions and Parameters Quiz

Quiz
•
Other
•
12th Grade
•
Medium
ruth sutton
Used 2+ times
FREE Resource
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.
Create a free account and access millions of resources
Similar Resources on Wayground
20 questions
Promotional Strategies

Quiz
•
9th - 12th Grade
15 questions
Manufacturing Process

Quiz
•
9th - 12th Grade
21 questions
Turtle Graphics and Range in Python

Quiz
•
12th Grade
20 questions
Marketing Management Study Guide EOPA (Promotion Part. II)

Quiz
•
9th - 12th Grade
20 questions
Federalism

Quiz
•
9th - 12th Grade
15 questions
Practice (DEMAND & SUPPLY)

Quiz
•
1st - 12th Grade
16 questions
Levels of Organization

Quiz
•
10th - 12th Grade
21 questions
Mass media

Quiz
•
4th - 12th Grade
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Other
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
10 questions
Video Games

Quiz
•
6th - 12th Grade
28 questions
Ser vs estar

Quiz
•
9th - 12th Grade
13 questions
BizInnovator Startup - Experience and Overview

Quiz
•
9th - 12th Grade
16 questions
AP Biology: Unit 1 Review (CED)

Quiz
•
9th - 12th Grade
20 questions
Parallel lines and transversals

Quiz
•
9th - 12th Grade
9 questions
Geometry and Trigonometry Concepts

Interactive video
•
9th - 12th Grade
10 questions
Angle Relationships with Parallel Lines and a Transversal

Quiz
•
9th - 12th Grade