# That Blue Square Thing

## AQA Computer Science GCSE

May 2019: this area of the site is being built just now. I’m making progress but there are areas where there is no content yet. That will get added over the next 6 months or so.

### Programming Concepts - Data and Variables

Computer programs using data. The data can be stored, changed, manipulated and transferred within the program.

To store data we need to use variables - named areas of computer memory in which data can be stored.

Variable names should be easy for other programmers to understand what they represent. Most programmers start their variable names with a lowercase letter and then use an uppercase letter for each new word - but with no spaces. There are really good reasons for this - and in particular for not using a capital letter at the start.

# good variable names
catName <- "Tiddles"
catAge <- 7
catFoodFave <- "Salmon chunks"
carDances <- True

These names are all meningful and all use a standard naming structure.

Using meaningful variable names is important. Modern computing often involves teams of programmers working on the same project. If names don't make sense or conform to a style that everyone understands it is much harder for programmers to work together.

Code also has to be maintained - kept working, often over a period of years. It's likely that this will need to continue using new programmers, so again, using names that mean something helps massively.

Once you start to use subroutines it gets slightly harder to deal with variables. You can read more about local and global variables on the subroutines page

A specific type of variable you may come across is a constant. Constants are simply variables which cannot be changed - their value always stays the same after they are declared.

When constants are declared the standard way of naming them is to use CAPITALS for their names. This means that it's really easy for other programmers to know what the variable is a constant and not avariable.

# constant variables
PI <- 3.1415927
GRAVITY = 9.8
YEARGROUP <- 11

Using Python it makes no difference whether a variable is a constant or not - any variable in Python can be changed. In other languages the idea of a constant is much stronger and constants can not be changed.

#### Data Types:

Each piece of data stored needs to belong to one of five main data types:

• integer - whole number
• real number - decimal number
• character - a single keyboard character
• string - a sequence of characters which together make words, sentences or even whole books
• Boolean value - a special data type which can only have the value True or the value False
The data type of a variable limits what can be done with the data - you can't add an integer to a string, for example ("Doris" + 56 doesn't make any sense).

You can read more about strings, including how they work and some interesting things to do with them, on the Unit 3 page String Handling. This gets slightly technical so it might be best to leave it until you've learned about more programming techniques, but it's a good link to check out when you're revising.