Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

python functions

Total questions: 36

Worksheet time: 21mins

Name
Class
Date
1.

What is the default return value of a function that does not return any value explicitly?

a)

Int

b)

Float

c)

Double

d)

None

2.

What does the function header contain?

a)

The function name

b)

The function name and parameter list

c)

The parameter list

d)

The return value

3.

Which keyword is used for functions?

a)

func

b)

def

c)

define

d)

function

4.
What is a variable?
a)
A box(memory location) where you store values
b)
a type of graphics
c)
Data type
d)
a type of memory
5.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
6.

What will be the output?

name = "Dave"

print (name)

a)

Dave

b)

'Dave'

c)

name

d)

(name)

7.
When you have an error in your code what is the term to summarise finding and fixing that error?
a)
Error checking
b)
Debugging
c)
Syntax finder
d)
Error finder
8.
A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly
a)
True
b)
False
9.
What is Python?
a)
text based programming language
b)
word processor 
c)
spreadsheet
d)
block based programming language
10.
Which statement correctly assigns the string "Tanner" to the variable name?
a)
name  = print( "Tanner")
b)
input("Tanner")
c)
name = "Tanner"
d)
name = input("Tanner")
11.
What does the term 'debug' mean?
a)
Identify errors and fix them.
b)
Making a calculation
c)
A set of instructions
d)
Looking at code
12.
What does the print function do in python?
a)
It's a variable.
b)
It can input data.
c)

It displays an output

d)
It loops the code.
13.

What is the Python built-in function used to display numbers and text on the screen?

a)

print

b)

input

c)

output

d)

command

14.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
15.
The correct way to write a variable in Python?
a)
my_variable = 10
b)
my variable = 10
c)
my_variable is 10
d)
my_variable: 10
16.
In python the ' INTEGER data type' can be defined as...?
a)
holds alphanumeric data as text
b)
holds whole numbers
c)
holds numbers with a decimal point
d)
holds either ‘true’ or ‘false’
17.
In python the ' STRING data type' can be defined as...?
a)
holds alphanumeric text
b)
hold whole numbers
c)
holds numbers with a decimal point
d)
holds either a true or false value
18.
In python the ' FLOAT data type' can be defined as...?
a)
holds alphanumerical data
b)

holds whole numbers

c)

holds a decimal point in a number

d)
hold either true or false
19.
In python the ' BOOLEAN data type' can be defined as...?
a)
holds alphanumerical data
b)
holds whole numbers
c)
holds a number with a decimal point
d)
holds either true or false
20.
what is correct code for INTEGER in python?
a)
in
b)
ing
c)
int
21.

What is the output from the following code?

print ("hello world")

a)
Hello World
b)
hello world
c)
print hello world
22.
Which of the following is a float?
a)
new_var = 1234
b)
new_var = True
c)
new_var = 1.234
d)
new_var = "True"
23.

The requirements for printing a string in Python are:

a)

( ) , ! and " "

b)

( ) and !

c)

( ) and " "

d)

" " and !

24.

Line 6 is called

a)

function definition

b)

function call

c)

function name

25.

The code highlighted in blue is best defined as:

a)

function name

b)

function call

c)

function definition

d)

arguments

e)

parameters

26.

What is the output of the given code?

a)

10 20 10

b)

10

c)

20

d)

10 20

27.

What is the output of the given code?

a)

10 20 10 20

b)

10 20 10

c)

10 20 20

d)

Error

28.

Function header in Python contains _________________.

a)

function name

b)

list of parameters

c)

return type

d)

all the above

e)

Only A & B

29.
What will print?
a)
nothing
b)
5
c)
6
d)
an error message
30.
What will print?
a)
nothing
b)
5
c)
6
d)
an error message
31.
What will print?
a)
nothing
b)
7
c)
z
d)
12
32.
How many times will Boo print?
a)
none
b)
4
c)
5
d)
1
33.
How many times will Boo print?
a)
none
b)
4
c)
5
d)
1
34.
What will print?
a)
1 2
b)
1
c)
3
d)
5
35.

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

a)

Variable

b)

Loop

c)

Constant

d)

Parameter

36.

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 []: