Skip to content

Study Hub

Study Guides

This pupil-friendly study guide includes a unit summary, clear notes, common mistakes, and quick questions with answers.

Year 10 - Computing

Global and local variables in programs

Programming: subroutines

Unit Summary

In this unit pupils will be introduced to structured programming. They will explore the differences between functions and procedures and use functions to return values in programs. They will be introduced to the concept of scope and how parameters can be used to reduce the need for global variables.

Lesson Summary

You will learn to explain the difference between a local and global variable.

Key Notes

  • The scope of a variable determines where it can be accessed.
  • A local variable is a variable that is only accessible within a specific part of a program.
  • A global variable can be accessed anywhere in a program for the duration of the program's execution.

Vocabulary To Learn

  • scope: the section of the program where the variable can be accessed and modified
  • local variable: a variable that is defined and visible for use only in specific parts of a program e.g. within a subprogram
  • global variable: a variable that is accessible from all parts of a program

Common Mistakes To Avoid

  • Assigning a variable inside a function automatically makes it global.

3 Quick Questions (With Answers)

1. Describe the system or process from this lesson in clear steps.

The scope of a variable determines where it can be accessed. A local variable is a variable that is only accessible within a specific part of a program.

2. Define this computing term and give one practical example. 'scope'

the section of the program where the variable can be accessed and modified. Add one real device or system example to prove understanding.

3. Correct this common computing misconception.

Mistake: Assigning a variable inside a function automatically makes it global. Correction: A variable is local, unless it is specifically set as a global variable.

More Lessons In This Unit

Browse all guides in the Year 10 Computing guide library.