wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Functions in Python

Total questions: 16

Worksheet time: 16mins

Name
Class
Date
1.
What will print?
a)
nothing
b)
5
c)
6
d)
an error message
2.
What will print?
a)
nothing
b)
5
c)
6
d)
an error message
3.
What will print?
a)
nothing
b)
7
c)
z
d)
12
4.
How many times will Boo print?
a)
none
b)
4
c)
5
d)
1
5.
What will print?
a)
1 2
b)
1
c)
3
d)
5
6.

What term is used to describe data passed into a function?

a)

Variable

b)

Loop

c)

Constant

d)

Parameter

7.

Leo wants to create a function that will roll a dice. Which is the correct function definition header?

a)

def dice roll ():

b)

def diceroll ()

c)

def diceroll ():

d)

def diceroll []:

8.

__________ keyword is used for creating a function in Python.

a)

define

b)

fun

c)

def

d)

function

9.

The default return value of any function in Python is _______________.

a)

null

b)

0

c)

None

d)

Garbage value

10.

Select the advantages of functions

a)

Modular programming

b)

Code re-usability

c)

Improving clarity of the code

d)

All the above

11.

What function is used to output a message in python?

a)

print("")

b)

input=name

c)

print

d)

name=input

12.

What syntax would you use to create a name variable?

a)

name=input()

b)

input=name

c)

name=input{}

d)

name=INPUT

13.

Why would you use a loop?

a)

To repeat a piece of code

b)

To create a loop

c)

To input data

14.

Which of the following items are present in the function header?

a)

Function name only

b)

Both function name and parameter list

c)

parameter list only

d)

Return value

15.

What is the name given to that area of memory, where the system stores the parameters and local variables of a function call?

a)

a heap

b)

storage area

c)

a stack

d)

an array

16.

What Is The Output Of The Following Code Snippet?


def func(message, num = 1):

print(message * num)


func('Welcome')

func('Viewers', 3)

a)

Welcome

Viewers

b)

Welcome

ViewersViewersViewers

c)

Welcome

Viewers,Viewers,Viewers

d)

Welcome