warning

These resources will be removed by end of Summer Term 2025.

Switch to our new teaching resources now - designed by teachers and leading subject experts, and tested in classrooms.

Lesson details

Key learning points

  1. In this lesson, we will learn about the scope of variables. When a variable is initialised within a subroutine it cannot be easily accessed and modified by other subroutines. This lesson will teach us about the different levels of scope and show us how to access variables that are initialised within subroutines.

Licence

This content is made available by Oak National Academy Limited and its partners and licensed under Oak’s terms & conditions (Collection 1), except where otherwise stated.

Loading...

3 Questions

Q1.
What will be the return value based on the function call to_the_power(3,2)?
An image in a quiz
12
3
6
Correct answer: 9
Q2.
What will be the return value based on the function call find_highest(12,9)?
An image in a quiz
Correct answer: 12
3
9
No return value
Q3.
What will be the return value based on the function call multiple(30,3)?
An image in a quiz
No
Correct answer: Yes

5 Questions

Q1.
On which line is the global variable number assigned?
An image in a quiz
1
2
Correct answer: 5
6
Q2.
On which line is the local variable number assigned?
An image in a quiz
1
Correct answer: 2
5
6
Q3.
What value will line 8 output when this program is executed?
An image in a quiz
10
Correct answer: 15
5
There will be no output
Q4.
What will happen when this program is executed?
An image in a quiz
An error message because the global variable number is not defined
Correct answer: An error message because the local variable number is not defined
It will output 10
It will output 5
Q5.
On which line of code does constant declaration occur?
An image in a quiz
1
2
4
Correct answer: 7