Variables, Constants & Assignments (Edexcel GCSE Computer Science)

Revision Note

Variables, Constants & Assignments

What is a variable?

  • A variable is a named memory location that holds data that during the execution of a program, the data can change

  • Variables can store a variety of different types of data such as numbers, text or true/false values

  • To store data in a variable, the process of assignment is used

What is a constant?

  • A constant is fixed data that during the execution of a program cannot change

  • A constant can store a variety of different types of data, similar to variables

  • Pi is an example of a mathematical fixed value that would typically be stored as a constant

What is assignment?

  • Assignment is the process of storing data in a variable or constant under a descriptive name

  • Assignment is performed using the '=' symbol

Assigning variables & constants

Concept

Python


Variables

x = 3

name = "Save My Exams"


Constants

VAT = 0.2

PI = 3.142

Data Types

What is a data type?

  • A data type is a classification of data into groups according to the kind of data they represent

  • Computers use different data types to represent different types of data in a program

  • The basic data types include:

Data type

Used for

Example

Integer

Whole numbers

10, -5, 0

Real

Numbers with a fractional part

3.14, -2.5, 0.0

Character 

Single character

'a', 'B', '6', '£'

String

Sequence of characters

"Hello world", "ABC", "@#!%"

Boolean

True or false values

True, False

  • It is important to choose the correct data type for a given situation to ensure accuracy and efficiency in the program

  • Data types can be changed within a program, this is called casting

Last updated:

You've read 0 of your 10 free revision notes

Unlock more, it's free!

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Did this page help you?

James Woodhouse

Author: James Woodhouse

Expertise: Computer Science

James graduated from the University of Sunderland with a degree in ICT and Computing education. He has over 14 years of experience both teaching and leading in Computer Science, specialising in teaching GCSE and A-level. James has held various leadership roles, including Head of Computer Science and coordinator positions for Key Stage 3 and Key Stage 4. James has a keen interest in networking security and technologies aimed at preventing security breaches.

Lucy Kirkham

Author: Lucy Kirkham

Expertise: Head of STEM

Lucy has been a passionate Maths teacher for over 12 years, teaching maths across the UK and abroad helping to engage, interest and develop confidence in the subject at all levels.Working as a Head of Department and then Director of Maths, Lucy has advised schools and academy trusts in both Scotland and the East Midlands, where her role was to support and coach teachers to improve Maths teaching for all.