Variables
When programming it is often necessary to store a value for use later
on in the program.
A variable is a label
given to a location in
memory containing a
value that can be
accessed or changed.
Think of a variable as a
box with a label that
you can store
information in.
Example
Start
End
Match the Python code to the correct part of the flowchart.
Create a Python program based on the code above and
save it as variables.py. Press F5 to run it.
Input Name
Display Hello
+ name
Inputting Numbers
When inputting numbers into variables you need to tell
Python what data type to expect.
We use int to tell Python we are going to enter an integer (whole
number). We use float when working with decimal places.
Create a new program using this code and save it as
numbers.py.
We use str to convert a number into a string.