Examplary
Start for free
Oak ComputingTest · Computing

Global and local variables

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

  1. A procedure executes a list of commands when called. A function will execute a list of commands and also ___ a value.
  2. What code would correctly call the function calculate?def calculate(a, b): total = a + b print(f"{a} + {b} = {total}") return totalnum1 = 10num2 = 15
  3. 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)
  4. What Python keyword is used to share a value from a function to the rest of the program?
  5. A ___ can have one, several or no parameters.
  6. What is the definition of values held in the brackets of a subroutine call that are passed into a subroutine via the parameters?
  7. What value will be output when this program is executed?def example(): number = 10 print(number)number = 5example()
  8. What will be the output of this program?def multiply(a, b): answer = a * b return answerprint(multiply(2, 4))
  9. What will be the output of this program?def divide(a, b): answer = a / b return answerdivide(8, 2)print(answer)
  10. What will be the output of this program?def add(a, b): answer = a + b return answersolution = add(8, 4)print(solution)

License: OGL

Global and local variables · Examplary