Calculation

Python can be used to perform calculations. We can use different operators to do this.

The operators we can use are listed below:

We can carry out calculations in Python. The arithmetic operators we use to do this are:

+ addition

- subtraction

* multiplication

/ division

Task 1

Try to run the following statements in Python and see if there

print(1+6)

print(7-5)

print(3*9)

print(7/2)

Task 2

Try changing the calculations to new ones.

We can put the results of calculations into variables. These variables will not be string but

integer (whole numbers) or float (decimal).

a=10

b=2

c=a/b

print(c)

Try to use variables to perform the calculations.

Task 3

Complete this program so it uses addition on the two variables make c equal to 15 then

prints it.

a=7

b=8

c= to the answer

Task 4

Every variable has a given data type. The most common data types are:

String - ?

Integer ?

Float - ? Also known as real numbers

Boolean –

In some languages we have to tell the computer what data type a variable is going to be.

Python, on the other hand, is able to decide the data type of the variable according to what

value it is first given (or to use the correct term what it is initialised with). This can cause

problems when we try to do something with the wrong data type.

Extension

Create a program that uses if statements and operators to test conditions. You could make a program that will ask the person their age and then say whether or not the can purchase learn to drive a car.