
Python Functions Quiz
Authored by M Dwedari
Computers
11th Grade
Used 2+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
8 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Define a procedure in Python and provide an example.
def example_procedure: print('This is an example procedure')
function example_procedure(): print('This is an example procedure')
def example_procedure(): print('This is an example procedure')
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Explain the difference between a function definition and a function call in Python.
A function definition creates the function, while a function call executes the function.
A function definition executes the function, while a function call creates the function.
A function definition defines the input parameters, while a function call defines the output parameters.
A function definition creates a variable, while a function call executes the variable.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What are parameters in a Python function? Provide an example to illustrate.
Parameters in a Python function are defined outside the parentheses in the function definition. For example: def greet name:
Parameters in a Python function are defined inside the parentheses in the function definition. For example: def greet(name):
Parameters in a Python function are not necessary and can be omitted. For example: def greet():
Parameters in a Python function are defined after the function body. For example: def greet: name
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Differentiate between arguments and parameters in Python functions.
Parameters and arguments are the same thing in Python functions.
Parameters are defined in the function signature, while arguments are the actual values passed to the function.
Arguments are used in the function signature, while parameters are the actual values passed to the function.
Parameters are passed to the function, while arguments are defined in the function signature.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of the return statement in a Python function? Give an example.
The purpose of the return statement in a Python function is to print a value to the console.
The purpose of the return statement in a Python function is to pause the function execution.
The purpose of the return statement in a Python function is to exit the function and return a value to the caller.
The purpose of the return statement in a Python function is to skip to the next line of code.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Explain the concept of local variables in Python functions with an example.
A local variable in Python functions is a variable that can be accessed from any function within the same module.
Local variables in Python functions are declared using the 'var' keyword.
An example of a local variable in Python functions is: x = 10
An example of a local variable in Python functions is as follows: def my_function(): x = 10 print(x) In this example, the variable 'x' is a local variable within the function 'my_function'.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How can you modify a global variable inside a function in Python? Provide an example to illustrate.
In Python, a global variable inside a function can be modified using the 'global' keyword. For instance: y = 5 def modify_global(): global y y = 15 modify_global() print(y) # Output: 15
A global variable inside a function can be modified in Python using the 'local' keyword.
In Python, a global variable inside a function can be modified using the 'nonlocal' keyword.
A global variable inside a function can be modified in Python using the 'global' keyword outside the function.
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?