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
- 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)?
12
3
6
Q2.
What will be the return value based on the function call find_highest(12,9)?
3
9
No return value
Q3.
What will be the return value based on the function call multiple(30,3)?
No
5 Questions
Q1.
On which line is the global variable number assigned?
1
2
6
Q2.
On which line is the local variable number assigned?
1
5
6
Q3.
What value will line 8 output when this program is executed?
10
5
There will be no output
Q4.
What will happen when this program is executed?
An error message because the global variable number is not defined
It will output 10
It will output 5
Q5.
On which line of code does constant declaration occur?
1
2
4