J
2 years ago
Jamescountry asked

So why does the "" affect the mathematical solution in Python? Are string values and normal numeric values different? If so, why?

Kelish Rai
Expert
2 years ago
Kelish Rai answered

Yes, strings and numbers are different in terms of how different operations work on them. For example,

Numbers are used for mathematical calculations.

print(5 + 5)  # Output: 10

Strings are just text, even if they contain numbers.

print("5" + "5")  # Output: "55"

When you put numbers inside quotes, Python treats them as text instead of numbers. That’s why "5" + "5" gives "55" instead of 10—because Python is joining two strings together, not adding numbers.

Also, you'll learn these operations in the upcoming lessons.

Hope this helps. If you have a follow-up question, feel free to let me know. I'm happy to help.

Python
This question was asked as part of the Getting started with Python course.