WorksheetsPython Programming: Functions and Procedures
Total questions: 12
Worksheet time: 11mins
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 []:
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 subroutine and a function?
They are the same thing
A subroutine passes values back out to the program, a function does not
A function passes values back out to the program, a subroutine 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
Which of the following statements is not true?
Functions/subroutines are examples of reusable code
Functions and subroutines should always be used in programs
Using functions/subroutines make it easier to "deconstruct" a problem into smaller pieces
They can make programs easier to read and understand
What would the output be for the following program if the user enters 4 and 6?
10
14
16
error
