Python follows a fixed order while calculating. Today we will learn operators and see every step clearly.
Calm rule: You don’t need to memorize. You only need to understand the order once.
This comic makes the “order of operations” feel natural. (Place your
generated image as 0.png.)
Operators are the symbols Python uses to do calculations. You
have already used + in math. Python has a few more.
+ adds numbers- subtracts numbers* multiplies numbers/ divides and gives a decimal (float)// divides and removes the decimal part (floor
division)
% gives the remainder (useful in “even/odd” later)
** power (2**3 = 8)This table shows what each operator does and when Python evaluates it. You do not need to memorize this — use it for reference.
Python always evaluates higher precedence first. If two operators have the same precedence, Python goes left to right.
print(10 + 5) # 15 print(10 - 5) # 5 print(10 * 5) # 50 print(10 / 5) # 2.0 (always float) print(10 // 3) # 3 print(10 % 3) # 1 print(2 ** 3) # 8
Think of making batti–chokha. You must do steps in order: mesh flour first, then mix, then roast, then mash, and ghee comes last. If you change the order, the result becomes messy.
Python is a strict robot. It follows a safe order so everyone gets the same answer.
print(1 + 2 * 3) # 7 (2*3 first) print((1 + 2) * 3) # 9 (brackets force priority)
Take two numbers from the user and print Addition, Subtraction,
Multiplication using f"".
a = 10 b = 5 print(a + b) # addition print(a - b) # subtraction print(a * b) # multiplication print(a / b) # division (float)
print(10 // 3) # floor division -> 3 print(10 % 3) # remainder -> 1 print(2 ** 3) # power -> 8
Note: / always gives a decimal result.
// removes the decimal part.
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print(f"Addition = {a + b}")
print(f"Subtraction = {a - b}")
print(f"Multiplication = {a * b}")
print(10 + 2 * 3) # 16 print((10 + 2) * 3) # 36
Try: 6+7*4/2, 1+2*3,
2**3 + 10//3
This evaluator is designed for beginners: numbers + operators. Keep it simple and clear.
This runs Python directly in the page using Pyodide. First run may take a few seconds. Input will appear as browser prompts.
Output will appear here…