How To Code in Python Sample Pages 9781510461826
How To Code in Python Sample Pages 9781510461826
Python
GCSE, iGCSE, National 4/5 and Higher
Greg Reid
■ changes the text or performs simple mathematical calculations with numbers (process)
In programming, the user is the person who will use the executing (running) program.
Variables
The second line of the code in Example 3 above creates a variable (or storage location)
called "userName". When the user types the name (enters text) and then presses enter,
the keyboard input "Greg" is stored in the variable.
You might want to imagine variables as boxes that your program Gre
temporarily stores data in while it's running. g
A variable can be given almost any name made up of letters and
numbers. Some exceptions to this are: userN
ame
■ You cannot use two or more separate words as a variable name.
Note that this book uses camel case (using capital letters in the
middle of a word) in place of two words. For example, "userName" instead
of "user name".
■ In Python, variable names should always start with a lower case letter. This is because
10 For this puzzle, state the two inputs that would produce the output shown below.
Output
Love the life you live. Live the life you love.