Why 5 + 3 = 53 in Python (And How to Fix It)

Опубликовано: 25 Июль 2026
на канале: One Step Clearer
33
1

Why does Python think 5 + 3 is 53? In this video, we dissect how Python handles user input and build an interactive calculator using type casting.

You'll learn how to turn text input into whole integers and decimal floats so you can perform actual calculations in your code instead of gluing text together.

📝 CODE WRITTEN IN THIS VIDEO:
--------------------------------------
Converting to whole numbers (integers)
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print(num1 + num2)

Converting to decimal values (floats)
num1 = float(input("Enter first number: "))


🧠 BONUS CHALLENGES:
--------------------------------------
Test your understanding with these unique practice challenges! Drop your answers in the comments below.

Challenge 1:
What is the output of this code?
x = float("1.5")
y = int("2")
print(x * y)

Options:
A) 3.0
B) "1.51.5"
C) Error

Challenge 2:
What happens if you run the following code?
value = int("5.5")
print(value)

Options:
A) It prints 5 (rounds down)
B) It prints 6 (rounds up)
C) It throws an Error

#python #programming #coding #pythontutorial #learnpython #compscience