Fostering Friendships - Enhancing Social Bonds in the Classroom
Programming Variables
1.
2. WHAT IS A VARIABLE?
A variable is a value in a program that can be changed when you are
running the program.
Variable need to be given names e.g. (“name”, “age”, “gender”)
Variable are written in a program as follows:
age = 14
However if you want to change the variable while running your program you
need to write it in the code like this:
age = input(“How old are you?”)
3. INSERTING A VARIABLE
In the blank window that opens type in the following.
print("Hello")
print("My name is Python")
name = input(“What is your name?”)
Print((“Hello”, name)
input("Please press enter to exit")
This is where you create
a variable. And output it
onto the screen
4. RUNNING YOUR PROGRAM
To run your program press F5 on the keyboard, you
will then see the following
Click OK you may see the following click OK on this and then you can save
the file in your folders, once you have done this your file will run in the
shell..
5. WHAT OUTPUT SHOULD YOU SEE
If you type in
your name when
asked and press
enter the
program will run
as shown