Variables and Constants Flashcards

OCR GCSE J277 Computer Science specification

Variable

A named storage location in memory that can hold a value which may change during program execution.

1 / 10

Ready to master these flashcards?

Sign in to study with spaced repetition and track your progress.

Sign In to Track Progress

Terms in this set (10)

1

Variable

A named storage location in memory that can hold a value which may change during program execution.

2

Constant

A named storage location in memory that holds a value which cannot change during program execution.

3

Purpose of variables

To store data that can be used and modified during the execution of a program.

4

Purpose of constants

To store data that remains the same throughout the execution of a program, improving readability and reducing errors.

5

Declaring a variable

Creating a variable by specifying its name and optionally assigning it an initial value.

6

Declaring a constant

Creating a constant by specifying its name and assigning it a value that cannot be changed.

7

Example of a variable

score = 0 (a variable named 'score' is created and assigned the value 0).

8

Example of a constant

PI = 3.14 (a constant named 'PI' is created and assigned the value 3.14).

9

Advantages of using constants

Improves code readability, prevents accidental changes, and makes updates easier if the value needs to be changed in the future.

10

Difference between variables and constants

Variables can change their value during program execution, while constants cannot.

Genie

Want to Learn More?

Get personalised lessons, quizzes, and instant feedback from your AI tutor.

Start Learning