Loading lesson…
Variables are named boxes for data. You'll write your first ten, then use AI to decode error messages and grow your intuition for types.
In Python, you create a variable by typing a name, an equals sign, and a value. Python figures out the type automatically. That is both its magic and its trap — the moment you mix types wrong, it yells.
# The four types you will use every day
name = "Maya" # str (text)
age = 13 # int (whole number)
height_m = 1.58 # float (decimal)
is_student = True # bool (True or False)
print(f"{name} is {age} years old.")
print(f"Type of age: {type(age).__name__}")Run this in any Python 3.12+ file. The f-string in the print statement embeds variables directly.user_input = input("Your age? ") # input() always returns str
age = int(user_input) # cast to int for math
next_year = age + 1
print(f"Next year you'll be {next_year}.")
# The classic bug: forgetting to cast
bad = user_input + 1 # TypeError: can only concatenate str (not "int") to strinput() returns a string. You must cast it before doing math.| Python | TypeScript | What's similar |
|---|---|---|
| name = "Maya" | const name = "Maya"; | Name = value |
| age = 13 | const age: number = 13; | TS asks for the type explicitly |
| is dynamic (type inferred) | is static (type checked) | Python finds bugs at runtime; TS finds them before you run |
Big idea: Python infers types so you write less, but mistyped values still blow up. Pair every new variable with a quick 'what type is this?' check in your head — and if you cannot tell, ask your AI.
15 questions · take it digitally for instant feedback at tendril.neural-forge.io/learn/quiz/end-prog-python-variables-builders
What is the core idea behind "Python Variables & Types — With an AI Explainer Beside You"?
Which term best describes a foundational idea in "Python Variables & Types — With an AI Explainer Beside You"?
A learner studying Python Variables & Types — With an AI Explainer Beside You would need to understand which concept?
Which of these is directly relevant to Python Variables & Types — With an AI Explainer Beside You?
Which of the following is a key point about Python Variables & Types — With an AI Explainer Beside You?
Which of these does NOT belong in a discussion of Python Variables & Types — With an AI Explainer Beside You?
What is the key insight about "Ask AI to explain, not just generate" in the context of Python Variables & Types — With an AI Explainer Beside You?
What is the key insight about "Variables are not labels on boxes — they are name tags on values" in the context of Python Variables & Types — With an AI Explainer Beside You?
What is the recommended tip about "Review before you run" in the context of Python Variables & Types — With an AI Explainer Beside You?
Which statement accurately describes an aspect of Python Variables & Types — With an AI Explainer Beside You?
What does working with Python Variables & Types — With an AI Explainer Beside You typically involve?
Which best describes the scope of "Python Variables & Types — With an AI Explainer Beside You"?
Which section heading best belongs in a lesson about Python Variables & Types — With an AI Explainer Beside You?
Which section heading best belongs in a lesson about Python Variables & Types — With an AI Explainer Beside You?
Which of the following is a concept covered in Python Variables & Types — With an AI Explainer Beside You?