COMPUTING
NERDS.COM
A PLACE TO LEARN PYTHON PROGRAMMING
ASSIGNMENT



Variables are used to store datum (single items of data). Since the purpose of computer programs is to collect, process and output data this makes variables very important. A variable is a location in computer memory where data is stored. Computer games store the following as variables: HEALTH, GOLD, EXP, INVENTORY, LEVEL etc. ASSIGNMENT is when we tell the computer to use a variable to store data. We ASSIGN variables like this:



Imagine a computer game that asks you to type in the name of your hero. How does it remember the heroes name? It uses a variable to store it for later. It will look something like this in python:

name = inp("Enter Heroes name")

The program will put the heroes name in every time we use the name variable. The game code may look like this:

print ("well done, ",name)