How To add,subtract,multiply and divide on Python


To Type in python version 2.7:

#!/usr/bin/python

print"hello"
print"Please type in your first number"
a=input()
print"Please type in your second number"
b=input()

c= a + b
d=a - b
e=a * b
f=a / d


print"the addition is",c
print"the subtraction is",d
print"the multiplication is",e
print"the division is",f


To Type in python version 3.3 and above:

#!/usr/bin/python

print("hello")
print("Please type in your first number")
a=input()
print("Please type in your second number")
b=input()

c= a + b
d=a - b
e=a * b
f=a / d


print("the addition is",c)
print("the subtraction is",d)
print("the multiplication is",e)
print("the division is",f)

Post a Comment