WorksheetsGlobal and local variables
Total questions: 10
Worksheet time: 7mins
A variable declared within a subroutine
Global
Local
A variable declared in the main program
Global
Local
Which of the following is an advantage of using local variables?
They allow the variable to be used throughout the whole program
They allow variable identifiers to be reused each time
They are easier to program than global variables
A wider range of data types can be used
What term is used to describe data passed into/out of a program?
Variable
Loop
Constant
Parameter
Leo wants to create a subroutine that will roll a dice. Which syntax is correct?
def dice roll ():
def diceroll ()
def diceroll ():
def diceroll []:
Which is the correct output for this program?
bacon local ,spam local, bacon local, global
spam local, bacon local, bacon local, global
global, bacon local, spam local, bacon local,
global, spam local, bacon local, bacon local
What will be the output of this code?
spam
main program
What will be the output of this code?
spam
bacon
main program
The output of the code above is
40
30
syntax error
