Thursday, 19 April 2012

Simple Calculations in Python

Simple Calculations

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

Now 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.

Monday, 9 April 2012

More Python Programming

The Python Programming tutorial continues. Looking at simple variables, and using them in simple loops. Counters and loops are important to programming. They for the basis of most of the programming structures.

So what is a variable?
These things are what makes computer programes work
Lets us see if we can make some

Variables are little boxes inside the memory of the computer that store things.
Lets make on and put something in it.

Here is a simple program
box = 1 # Put 1 in a box
This line makes a variable box and puts the number 1 in it.
print box
We Print out what is in the variable box.
Here is the code
box = 1
print box
What's that thing after the 1
This is a comment. It doesn't do anything for the program. It is here to help you understand what is going on.
Lets make the program a bit easier to read.

There are solutions and more on the website