# Scope

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.

#### Unit quizzes are being retired in August 2023

Why we're removing unit quizzes from the website >
Quiz:

# Intro quiz - Recap from previous lesson

Before we start this lesson, let’s see what you can remember from this topic. Here’s a quick quiz!

Q1.What will be the return value based on the function call to_the_power(3,2)?

1/3

Q2.What will be the return value based on the function call find_highest(12,9)?

2/3

Q3.What will be the return value based on the function call multiple(30,3)?

3/3

#### Unit quizzes are being retired in August 2023

Why we're removing unit quizzes from the website >
Quiz:

# Intro quiz - Recap from previous lesson

Before we start this lesson, let’s see what you can remember from this topic. Here’s a quick quiz!

Q1.What will be the return value based on the function call to_the_power(3,2)?

1/3

Q2.What will be the return value based on the function call find_highest(12,9)?

2/3

Q3.What will be the return value based on the function call multiple(30,3)?

3/3

# Video

Click on the play button to start the video. If your teacher asks you to pause the video and look at the worksheet you should:

• Click "Close Video"
• Click "Next" to view the activity

Your video will re-appear on the next page, and will stay paused in the right place.

# Worksheet

These slides will take you through some tasks for the lesson. If you need to re-play the video, click the ‘Resume Video’ icon. If you are asked to add answers to the slides, first download or print out the worksheet. Once you have finished all the tasks, click ‘Next’ below.

#### Unit quizzes are being retired in August 2023

Why we're removing unit quizzes from the website >
Quiz:

# Scope

Don’t worry if you get a question wrong! Forgetting is an important step in learning. We will recap next lesson.

Q1.On which line is the global variable number assigned?

1/5

Q2.On which line is the local variable number assigned?

2/5

Q3.What value will line 8 output when this program is executed?

3/5

Q4.What will happen when this program is executed?

4/5

Q5.On which line of code does constant declaration occur?

5/5

#### Unit quizzes are being retired in August 2023

Why we're removing unit quizzes from the website >
Quiz:

# Scope

Don’t worry if you get a question wrong! Forgetting is an important step in learning. We will recap next lesson.

Q1.On which line is the global variable number assigned?

1/5

Q2.On which line is the local variable number assigned?

2/5

Q3.What value will line 8 output when this program is executed?

3/5

Q4.What will happen when this program is executed?

4/5

Q5.On which line of code does constant declaration occur?

5/5

# Lesson summary: Scope

## Time to move!

Did you know that exercise helps your concentration and ability to learn?

For 5 mins...

Move around:
Jog

On the spot:
Dance