WorksheetsPython Functions and Ifs
Total questions: 20
Worksheet time: 58mins
What term is used to describe data passed into a function?
Variable
Loop
Constant
Parameter
Leo wants to create a function that will roll a dice. Which is the correct function definition header?
def dice roll ():
def diceroll ()
def diceroll ():
def diceroll []:
Do you call or define a function first?
call
define
Rewrite this line of code correctly!
(a)
Rewrite this line of code correctly!
(a)
What is a return in a function?
Keyword that tells the function what to print
Keyword that tells the function what value to send back
Keyword that tells the function what to add
Keyword that tells the function what parameter to pass
What are the reasons for using functions? Select all that apply.
To build code that will be reused
To simplify code
To add comments
To help organize longer programs
__________ keyword is used for creating a function in Python.
define
fun
def
function
square(5)
What is the syntax for defining a user defined function in Python?
def function_name(parameters):
function_name(parameters)
function_name:
function_name(parameters):
Which symbol means "not equal to"?
==
<=
>=
!=
Which character must be at the end of the line for if?
:
;
.
{
What does the = = symbol mean in Python?
Equal to or shows equality
Not Equal
Code that will be skipped
End of clause
What is the output?
True
False
condition1
condition2
What will this program output?
:(
":("
Error
nothing
What would be outputted here?
it divides by 7!
it divides by 3.
It divides by 7!
It divides by 3.
What is the output of the code? Remember that integers and strings are different
"String"
"No string"
18
none of the above
