# Type conversion — telling Python to treat a value as a different type
# Four main functions: int(), float(), str(), bool()

# ─────────────────────────────────────────────
# str to int
# ─────────────────────────────────────────────

age = "25"
print(type(age))     # <class 'str'>

age = int(age)
print(age)           # 25
print(type(age))     # <class 'int'>

# ─────────────────────────────────────────────
# str to float
# ─────────────────────────────────────────────

height = float("1.75")
print(height)        # 1.75
print(type(height))  # <class 'float'>

# ─────────────────────────────────────────────
# int to str
# ─────────────────────────────────────────────

score = str(100)
print(score)         # 100
print(type(score))   # <class 'str'>

# Now you can concatenate
print("Your score: " + score)   # Your score: 100

# ─────────────────────────────────────────────
# int to float
# ─────────────────────────────────────────────

price = float(5)
print(price)         # 5.0
print(type(price))   # <class 'float'>

# ─────────────────────────────────────────────
# float to int — truncates, never rounds
# ─────────────────────────────────────────────

result = int(3.9)
print(result)        # 3 — not 4

result = int(3.1)
print(result)        # 3

# ─────────────────────────────────────────────
# bool() — what converts to False?
# ─────────────────────────────────────────────

print(bool(1))       # True
print(bool(0))       # False — zero is False

print(bool("Bull"))  # True
print(bool(""))      # False — empty string is False

print(bool(3.14))    # True
print(bool(0.0))     # False — zero float is False

# The rule: empty, zero, and nothing = False. Everything else = True.

# ─────────────────────────────────────────────
# What doesn't work
# ─────────────────────────────────────────────

# int("Bull")   # ValueError — can't convert text to int
# float("abc")  # ValueError — same reason

# Only convert compatible values
print(int("25"))     # 25  — works
print(float("3.14")) # 3.14 — works
# print(int("3.14")) # ValueError — "3.14" is not a whole number string

# ─────────────────────────────────────────────
# Real example — input() always returns string
# ─────────────────────────────────────────────

age = int(input("Enter your age: "))
height = float(input("Enter your height in m: "))

print(f"Age: {age} | Height: {height}")
print(type(age))     # <class 'int'>
print(type(height))  # <class 'float'>
