What is Type Conversion?

Implicit Type Conversion (Automatic): Python automatically converts one data type to another when it makes sense.

x = 5
y = 2.5
result = x + y     # x is implicitly converted to float
print(result)

# Output: 7.5       #float

What is Type Casting?

Explicit Type Conversion: The process where you manually convert one data type to another using Python’s built-in functions.

x = "10"
y = int(x)     # Convert string to int using type casting
z = 20
print(y+z)   

## Output: 30    #int

download (3).png