🐸

Words & Numbers

Python Basicspython-basics-04-words-and-numbers
Reward: 50 XP
|

Different Kinds of Magic

Hoppy discovers that 5 and "5" look similar, but they are completely different kinds of magic.

The Experiment

print(5 + 5)      # Result: 10 (Math)
print("5" + "5")  # Result: "55" (Sticking together)
  • Integer (int): Numbers for math. No quotes.

  • String (str): Text for reading. Has quotes.

Your Mission

1
Math Addition

Create a variable math_result equal to 10 + 10.

2
Text Addition

Create a variable text_result equal to "10" + "10".

3
Observe

Print both variables to see the difference.

Suggested Solution
Click to expand
math_result = 10 + 10
text_result = "10" + "10"

print(math_result)
print(text_result)
Advanced Tips
Want more? Click to expand

You can check the type of any magic box using the type() spell.

print(type(5))
print(type("5"))

Try running this code to see the difference!

pymain.py
Loading...
Terminal
Terminal
Ready to run...