Addition of Numbers
x = 5
y = 7
z = x + y
print(z)
12
The value of 5 is stored in x and the value of 7 is stored in y. The result of the addition of x and y is stored in z (which is 12). To collect user input we use the method input
num1 = float(input('Enter a number: '))
num2 = float(input('Enter another number: '))
sum_num = num1 + num2
print('Addition', sum_num)
#float is the data type of the number I would like to collect. It could also be int for integer and str for string
Subtraction of Numbers
num1 = float(input('Enter a number: '))
num2 = float(input('Enter another number: '))
sub_num = num2 - num1
print('Subtraction', sub_num)
Division of Numbers
num1 = float(input('Enter a number: '))
num2 = float(input('Enter another number: '))
div_num = num1 /num2
print(div_num)
Multiplication of Numbers
num1 = float(input('Enter a number: '))
num2 = float(input('Enter another number: '))
mult_num = num1 * num2
print(mult_num)
Modulus of Number
num1 = float(input('Enter a number: '))
num2 = float(input('Enter another number: '))
mod_num = num1 % num2
#Modulus returns the remainder after successful division.
Floor of Number
num1 = float(input('Enter a number: '))
num2 = float(input('Enter another number: '))
floor_num = num1 // num2
#Floor returns the whole number after the successful division.
Exponential
num1 = float(input('Enter a number: '))
num2 = float(input('Enter another number: '))
exp_num = num1 ** num2
#raises the first number by the second number
The order of operation of arithmetic operation is PEMDAS. Parenthesis, Exponential, Multiplication, Division, Addition, Subtraction.