The starter and exit quiz of the lesson “Global and local variables”, from the unit “Programming: subroutines” (Year 10 Computing) by Oak National Academy.
Free to use. Edit it, share it and hand it out to your students.
Oak National Academy
10 questions
A procedure executes a list of commands when called. A function will execute a list of commands and also ___ a value.
What code would correctly call the function calculate?def calculate(a, b): total = a + b print(f"{a} + {b} = {total}") return totalnum1 = 10num2 = 15
What are the parameters in this program?def calculate(a, b): total = a + b print(f"{a} + {b} = {total}") return totalnum1 = 10num2 = 15calculate(num1, num2)
What Python keyword is used to share a value from a function to the rest of the program?
A ___ can have one, several or no parameters.
What is the definition of values held in the brackets of a subroutine call that are passed into a subroutine via the parameters?
What value will be output when this program is executed?def example(): number = 10 print(number)number = 5example()
What will be the output of this program?def multiply(a, b): answer = a * b return answerprint(multiply(2, 4))
What will be the output of this program?def divide(a, b): answer = a / b return answerdivide(8, 2)print(answer)
What will be the output of this program?def add(a, b): answer = a + b return answersolution = add(8, 4)print(solution)