In Part 2, we understood variables and data types. Now we move to the next core layer: how Python performs actions and decisions.
Operators are symbols that tell Python what action to perform on values. Without operators, programs cannot think or decide.
+ Addition- Subtraction* Multiplication/ Division// Floor Division% Modulus** Power
a = 10
b = 3
print(a + b)
print(a - b)
print(a * b)
print(a / b)
print(a // b)
print(a % b)
print(a ** b)
Floor division removes decimal part. This is critical in pagination, indexing, and memory calculations.
== Equal to!= Not equal> Greater than< Less than>= Greater or equal<= Less or equal
age = 18
print(age >= 18)
print(age == 21)
Comparison operators always return True or False.
andornot
age = 20
has_id = True
print(age >= 18 and has_id)
print(age < 18 or has_id)
print(not has_id)
Logical operators are the foundation of authentication, permissions, and decision systems.
An expression is a combination of values and operators that produces a result.
result = (10 + 5) * 2
print(result)
Python allows programs to accept input
using the input() function.
name = input("Enter your name: ")
print("Hello", name)
Important:
input() always returns a string.
age = int(input("Enter your age: "))
print(age + 1)
Without conversion, calculations will fail.
x = 10
y = 20
print(x, y)
print("Sum =", x + y)
Operators and expressions define how programs think, compare, and decide. Every API, AI model, and backend logic depends on this layer.
Next part will introduce control flow — if, else, and decision-making structures.