wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Functions Quiz

Total questions: 9

Worksheet time: 5mins

Name
Class
Date
1.

What is a function in Python?

a)

A type of data structure in Python

b)

A block of reusable code that performs a specific task.

c)

A built-in module in Python

d)

A keyword used to define a variable in Python

2.

What is the keyword used to define a function in Python?

a)

def

b)

define

c)

function

d)

func

3.

What is the syntax for calling a function in Python?

a)

function_name()

b)

functionName{}()

c)

functionName[]

d)

functionName{}

4.

What is the purpose of a return statement in a function?

a)

To print a message to the console

b)

To stop the execution of the function

c)

To specify the value that a function should return

d)

To declare a new variable

5.

What are parameters in a function?

a)

Variables used to receive input values when the function is called

b)

Variables used to store output values when the function is called

c)

Random values generated within the function

d)

Constants used to define the function's behavior

6.

What is the difference between parameters and arguments in a function?

a)

Parameters and arguments are interchangeable terms in a function.

b)

Parameters are the actual values passed to the function, while arguments are in the function definition.

c)

Parameters are in the function definition, while arguments are the actual values passed to the function.

d)

Parameters are only used in built-in functions, while arguments are used in user-defined functions.

7.

How do you pass arguments to a function in Python?

a)

By specifying the arguments within the parentheses when defining the function.

b)

By leaving the parentheses empty when defining the function.

c)

By specifying the arguments after the 'return' keyword when defining the function.

d)

By using square brackets to enclose the arguments when defining the function.

8.

What is the scope of a variable in a function?

a)

Global to the function

b)

Restricted to the class

c)

Accessible from any function

d)

Local to the function

9.

What is a recursive function in Python?

a)

A function that only works with integers

b)

A function that can only be used once

c)

A function that calls itself within its definition

d)

A function that doesn't return any value