Storing data and understanding what kind it is
name = "Ada"
age = 28
height = 5.7
is_student = True
print(name)
print(age)str — text (strings): "hello", 'world'int — whole numbers: 42, -7, 0float — decimal numbers: 3.14, -0.5bool — True or False (always capitalized)type():print(type("hello")) # <class 'str'>
print(type(42)) # <class 'int'>
print(type(3.14)) # <class 'float'>
print(type(True)) # <class 'bool'>"5" (a string) and 5 (an integer) are completely different to Python:x = "10"
y = int(x) # Convert string to int
print(y + 5) # 15
z = str(100) # Convert int to string
print("Score: " + z)"age: " + 25 will crash. Either convert with str() or use an f-string (you'll learn those next lesson).name and Name are different)snake_case by convention: my_variable, not myVariableCreate four variables — one for each type (str, int, float, bool). Print each variable along with its type using `type()`.
loading editor...
Ask about Variables & Types
◇
Hey! I'm your AI tutor.
Ask me anything about this lesson, or paste code you're stuck on.
AI tutor is a premium feature