7.1.5

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

1Components of a Computer

2Software & Software Development

3Exchanging Data

4Data Types, Data Structures & Algorithms

5Legal, Moral, Cultural & Ethical Issues

6Elements of Computational Thinking

6.1Thinking Abstractly

6.2Thinking Ahead

6.3Thinking Procedurally

6.4Thinking Logically

6.5Thinking Concurrently

7Problem Solving & Programming

8Algorithms

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