Variables
A variable is when one letter or word is used to represent a different letter, word, number, or value. One way to think of a variable is to imagine that you are programming a computer so that it can make memories. For example, my name is Jessica. If I am writing a computer program and I want that program to remember my name, I will assign my name to a variable. This will look like name = 'Jessica'
. The variable is name
. Jessica
in the memory.
Perhaps I would like the computer to remember something else about me as well. Maybe I want the computer program to remember that I am 64 inches, or roughly 128 cm, tall. I will say height_inches = 64
or height_centimeters = 128
. The variables here are height_inches
and height_centimeters
. The memories are my height in inches and my height in centimeters.
Why don't you try giving a computer the name
variable with your name and then a height
variable with your height?
First, open your Python shell and type the following code:
name = 'yourname'...