2.3.2

Scope

Test yourself

Scope

The scope of a variable is the group of areas of the code from which it can be accessed.

Illustrative background for Local scopeIllustrative background for Local scope ?? "content

Local scope

  • A variable defined within a subroutine will have local scope.
  • This means that they can only be accessed within that subroutine.
Illustrative background for Global scopeIllustrative background for Global scope ?? "content

Global scope

  • A variable can be made global by adding the 'global' keyword in front of it when it is first used.
  • Global variables may be accessed by any part of the whole program.

Jump to other topics

1Problem Solving

2Programming

3Data

4Computers

5Communication & The Internet

6The Bigger Picture

Unlock your full potential with Seneca Premium

  • Unlimited access to 10,000+ open-ended exam questions

  • Mini-mock exams based on your study history

  • Unlock 800+ premium courses & e-books

Get started with Seneca Premium