Python Full Tutorial — Part 3

In Part 2, we understood variables and data types. Now we move to the next core layer: how Python performs actions and decisions.

What is an Operator?

Operators are symbols that tell Python what action to perform on values. Without operators, programs cannot think or decide.

Arithmetic Operators

Arithmetic Example

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)
  

Why Floor Division Matters

Floor division removes decimal part. This is critical in pagination, indexing, and memory calculations.

Comparison Operators

Comparison Example

age = 18

print(age >= 18)
print(age == 21)
  

Comparison operators always return True or False.

Logical Operators

Logical Thinking Example

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.

What is an Expression?

An expression is a combination of values and operators that produces a result.

Expression Example

result = (10 + 5) * 2
print(result)
  

Input from User

Python allows programs to accept input using the input() function.

Basic Input Example

name = input("Enter your name: ")
print("Hello", name)
  

Important: input() always returns a string.

Converting Input Type

Type Conversion

age = int(input("Enter your age: "))
print(age + 1)
  

Without conversion, calculations will fail.

Output with print()

Multiple Output Styles

x = 10
y = 20

print(x, y)
print("Sum =", x + y)
  

Why This Part is Critical

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.

Disclaimer:
This tutorial is for educational purposes only. Practice is required to master programming concepts.