# COMMON NUMBER MISTAKES
# Each block shows the wrong assumption and what Python actually does
# Read through — don't just run it top to bottom

# ─────────────────────────────────────────────
# MISTAKE 1 — Division always returns float
# ─────────────────────────────────────────────

result = 10 / 2
print(result)        # 5.0 — not 5
print(type(result))  # <class 'float'>

# Fix — use floor division if you need an int
print(10 // 2)       # 5
print(type(10 // 2)) # <class 'int'>

# ─────────────────────────────────────────────
# MISTAKE 2 — int() truncates, doesn't round
# ─────────────────────────────────────────────

print(int(3.9))   # 3 — not 4
print(int(3.1))   # 3
print(int(-3.9))  # -3 — toward zero, not -4

# Fix — use round() if you want rounding
print(round(3.9))  # 4
print(round(3.1))  # 3

# ─────────────────────────────────────────────
# MISTAKE 3 — Float precision
# ─────────────────────────────────────────────

print(0.1 + 0.2)          # 0.30000000000000004
print(0.1 + 0.2 == 0.3)   # False — not a Python bug

# Fix — round when comparing floats
print(round(0.1 + 0.2, 1) == 0.3)  # True

# ─────────────────────────────────────────────
# MISTAKE 4 — Mixing string and number
# ─────────────────────────────────────────────

age = "25"
# print(age + 5)   # TypeError — uncomment to see the error

# Fix — convert first
age = int(age)
print(age + 5)   # 30

# input() always returns string — always convert
# age = int(input("Enter your age: "))

# ─────────────────────────────────────────────
# MISTAKE 5 — Dividing by zero
# ─────────────────────────────────────────────

# print(10 / 0)   # ZeroDivisionError — uncomment to see the error

# Fix — check before dividing
divisor = 0
if divisor != 0:
    print(10 / divisor)
else:
    print("Cannot divide by zero")

# ─────────────────────────────────────────────
# MISTAKE 6 — Forgetting operator precedence
# ─────────────────────────────────────────────

print(2 + 3 * 4)    # 14 — multiplication first
print((2 + 3) * 4)  # 20 — parentheses first

# ─────────────────────────────────────────────
# MISTAKE 7 — Banker's rounding
# ─────────────────────────────────────────────

print(round(0.5))   # 0 — not 1
print(round(1.5))   # 2
print(round(2.5))   # 2 — not 3
print(round(3.5))   # 4

# Python rounds to the nearest even number when exactly halfway
# This is by design — not a bug
