Learning to Program in Python for Kids

of all ages and Linux on a Raspberry Pi by Philip M Russell


Using variables for calculations

Pi Python Character

Let us do a simple sum

We will make 3 variables.

box, bigbox and answer. We will put 2 in the box, 12 in bigbox and nothing in answer.

Here is the code

box = 2 # Put 2 in a variable box
bigbox = 12 # Put 12 in another variable box
answer = 0 # Here is an empty box containing nothing
answer = box + bigbox
print "The answer is ",answer

Pi Python CharacterNow its your go.

Make three variables, first , second and result.

Put 2 in first, 3 in second and nothing in result.

Add the numbers up in the program and then print the answer.

Solution