🏷️
Data Types
Strings, ints, floats, booleans, and more
Reward
+50 XP
Built-in types
Python has several built-in data types: str (text), int (whole numbers), float (decimals), bool (True/False), list, tuple, dict, set, and None.
print(type("hello")) # <class 'str'>
print(type(42)) # <class 'int'>
print(type(3.14)) # <class 'float'>
print(type(True)) # <class 'bool'>Type conversion
Convert between types with int(), float(), str(), bool().
x = "42"
y = int(x) # 42 as integer
z = float(x) # 42.0
print(y + 1) # 43Try it yourself
Run the example below. Edit it and see what changes.
main.py
Output
Press Run to execute (Ctrl/Cmd+Enter)
Common mistakes
- ⚠Confusing str '42' with int 42 — they behave differently with +.
- ⚠Forgetting that True equals 1 and False equals 0.
