number1 = 100
Set the value of a variable, if there is not a variable already created, it will create one. A variable is a container for a value (in this case the variable will be called “number1” and store the value 100). The value stored in the variable can change while the program is running. The variable can be called whatever you want (except Python dedicated words such as print, save, etc.) and it must start with a letter rather than a number or symbol and have no spaces.
answer = num1 + num2
Adds together num1 and num2 and stores the answer in a variable called answer.
answer = num1 – num2
Subtracts num2 from num1 and stores the answer in a variable called answer.
answer = num1 * num2
Multiplies num1 by num2 and stores the answer in a variable called answer.
answer = num1 / num2
Divides num1 by num2 and stores the answer in a variable called answer.
answer = num1 // num2
A whole number division (i.e. 9//4 = 2) and stores the answer in a variable called answer.
print (“This is a message”)
Displays the message in the brackets. As the value we want displayed is a text value it has the speech marks, which will not be displayed in the output. If you wanted to display a numerical value or the contents of a variable, the speech marks are not needed.
print (“First line\nSecond line”)
“\n” is used as a line break.
textValue = input(“Enter a text value: ”)
Displays the question “Enter a text value: ” and stores the value the user enters in a variable called textValue. The space after the colon allows a space to be added before the user enters their answer, otherwise they appear squashed unattractively together.
print (“The answer is”, answer)
Displays the text “The answer is” and the value of the variable answer.
numValue = int(input(“Enter a number: ”))
Displays the question “Enter a number: ” and stores the value as an
integer (a whole number) in a variable called numValue Integers can be used in calculations but variables stored as text cannot.