Worksheetspython functions
Total questions: 25
Worksheet time: 19mins
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 []:
Write the line of code that will call the function.
(a)
Write the line of code that will define the function, draw_coin
(a)
Do you call or define a function first?
call
define
Correctly rewrite this line of code!
(a)
Correctly rewrite this line of code !
(a)
Rewrite the line of incorrect code using Camel Case to make it correct!
Hint: The mistake is when the function gets called
(a)
What is the output of the given code?
10 20 10
10
20
10 20
Select the advantages of functions
Modular programming
Code re-usability
Improving clarity of the code
All the above
The parameters could be a
Variable
Literal
Expression
Function
What will be the output of this program?
0
1
2
3
4
The process of creating a function is as follows
1. Use the keyword def to declare the function
2. Follow with defining the function name
3. Add parameters to the function: they should be within the parentheses() of the function.
4. End this line with a colon after the parenthesis.
5. Indent and then add the statements that the functions should execute
6. Include a return statement if the function should output something. Without the return statement, your function will return an object - None
What is missing from this function?
return value statement
Variable
Function definition
Parameters
