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.
8 questions · take it digitally for instant feedback at tendril.neural-forge.io/learn/quiz/end-prog-python-variables-builders
What is the main idea of "Python Variables & Types — With an AI Explainer Beside You"?
Which concept is most central to "Python Variables & Types — With an AI Explainer Beside You"?
Which use of AI fits this topic best?
What should a careful learner remember about "Ask AI to explain, not just generate"?
You want to use AI after this lesson. What is the safest next step?
How should AI output about variables be treated?
Name one way to verify an AI answer about variables.
Which action would help you apply "Python Variables & Types — With an AI Explainer Beside You" responsibly?