Introduction: Teach Me Python #5: Simple Maths

Picture of Teach Me Python #5: Simple Maths

Today we will be learning how to preform simple maths operations in python such as adding, subtracting, multiplying and dividing. If you have any python related questions of want to suggest something for the python tutorial series please comment and as always favourite and subscribe.

Step 1: The Code

Picture of The Code

We will begin by coding a simple calculator so open up a blank python file and type the following code:

number1 = input("Enter the first number: )
number2 = input("Enter the second number: )
numberAdd = number1 + number2
numberMinus = number1 - number2
numberMultiply = number1 * number2
numberDivide = number1 / number2
print(number1, ' + ', number2, ' = ', numberAdd)
print(number1, ' - ', number2, ' = ', numberMinus)
print(number1, ' * ', number2, ' = ', numberMultiply)
print(number1, ' / ', number2, ' = ', numberDivide)

The symbols for each operation are:
multiply = *
divide = /
minus = -
plus = +
divide (logical) = // --does not use decimals, rounds it if it is
modulus = % //divides and calculates the remainder
And that is basic python maths

Comments

About This Instructable

469views

5favorites

License:

Bio: 1 new python tutorial every day Comment what you want the next one to be Please favourite and subscribe Notice Board: - since instructables has automatically ... More »
More by BlueBlood Studios:Teach Me Python #7: Control Statements Pt.2: While LoopsTeach My Python #6: Control Statements Pt.1: If, Else And ElifTeach Me Python #5: Simple Maths
Add instructable to: