WorksheetsPython procedures and functions
Total questions: 35
Worksheet time: 20mins
Leo wants to create a subroutine that will roll a dice. Which syntax is correct?
def dice roll ():
def diceroll ()
def diceroll ():
def diceroll []:
What would the output be from the program shown here? (assuming that the user enters "John" and "Smith"
John
Smith
John Smith
Error
What would the output be from this program?
Error
Hello
Hello, World
World
What is the difference between a procedure and a function?
They are the same thing
A procedure passes values back out to the program, a function does not
A function passes values back out to the program, a procedure does not
A function can run without being called
What will the output of this program be when it is run?
Nothing
Hello, world
It will generate an error
What will be the output of this program if the user enters "Han" and then "Solo"?
An error
Nothing
first surname
Han Solo
What would the output be for the following program if the user enters 4 and 6?
10
14
16
error
What is the term for the variables declared in the brackets of a function. eg
def setArea(radius):
What would be the term for radius?
Parameter
Argument
Global variable
function
What is the term for the values passed into the function or procedure?
setArea(r)
What would be the term for r?
Parameter
Argument
Global variable
function
A count controlled loop will..
Repeat code until a condition is met
Repeat code a specific amount of times
Repeat code a random amount of times
None of the above
Which of these is NOT a loop in python?
for loop
while loop
nested loop
if loop
Which of these operators means EQUAL TO?
'='
'=>'
'<='
'=='
What will be the output of this code?
1,2,3,4,5,6,7,8,9,10,11,12
0,2,4,6,8,10
2,4,6,8,10,12
2,4,6,8,10
Which of these will allow me to count from 0-20 in steps of 5?
for x in range(0,20):
print(x)
while x = (0,20,5):
print(x)
for x in range(0,21,5):
print(x)
for x in range(0,21,5):
print(y)
If i want to continuously check for a correct answer, what loop would i use?
for loop
while loop
guess=input()
guess=input()
guess=input()
guess=input()
Which word completes this sentence: "Iteration makes code more ___________"
Complex
Efficient
Simple
Straightforward
What will the output be for the code shown here?
3,2,1,0
0,1,2,3
3,2,1
1,2,3
Anil is writing a "rock, scissors, paper" program. He wants the game to repeat until the user doesn't want to play anymore. What loop should he use?
a FOR loop
a WHILE loop
Tara has written a "Hide and Seek Simulator" - what will happen when she runs it?
It will print "1,2,3,4,5,6,7,8,9,10 Coming ready or not!"
The program will not run
It will print "1,2,3,4,5,6,7,8,9,11 Coming ready or not!"
It will print ("10 Coming ready or not!")
4
3
2
1
3
2
1
0
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
......(repeated continuously)
False
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
(repeated continuously)
