design, write and debug programs that accomplish specific goals, including controlling or simulating physical systems; solve problems by decomposing them into smaller parts.
use logical reasoning to explain how some simple algorithms work and to detect and correct errors in algorithms and programs
LO: To use mathematical operations on the computer.
We are going to move away from Reeborg for this unit an work directly with Python using the development environment IDLE that comes with Python when you install it from here.
When you launch IDLE you will be presented with a window similar to this:
This is the Python Interpreter - think of it as a space where you can try things out without saving anything or making a program.
It is important to state at this stage that the commands we have used in Reeborg are not general Python commands - they only work in Reeborg's world. But the principles we have learnt are the same.
Let us start at the very basic level and see how Python performs with simple mathematical operations:
7 + 3 #when you press enter/return Python will return the answer 7+3 #this will give the same answer, but notice how the first example with spaces is easier to read. 10 - 3 7 * 3 #notice here that multiplication is represented by the star character 12 / 3 #notice here that division is represented by the forward slash character 12 % 3 #this is a special operation called modulus - it returns the remainder of a division calculation 15 % 4 #this will return 3 because 4 goes into 15 three times leaving a remainder of 3 #as an extension exercise you may wish to introduce brackets as a way of 'doing that calculation first' (2 * 3) + 4 2 * (3 + 4) #how do the brackets change the answer?
To get children familier with these commands you could get them to use the interpreter to act as a calculator to work out some maths questions.