📚
Assign Variables
What is a Variable?
Think of a variable as a labeled box. You give the box a name, put a value inside it, and later you can use that name to get the value back.
In Python, you create a variable by typing: name = value
age = 25
This creates a box labeled
age25age25The Three Main Types of Data
Python has different types of data, and it's important to understand them:
- ◆Integers (int) — whole numbers: ,
25,100-3 - ◆Floats (float) — decimal numbers: ,
5.9,3.14-0.5 - ◆Strings (str) — text, always in quotes: ,
"Alice"'hello'
name = "Alice" # This is a string (text) age = 25 # This is an integer (whole number) height = 5.9 # This is a float (decimal number) print(name) # → Alice print(age) # → 25 print(height) # → 5.9
Notice: strings need quotes, but numbers don't. If you wrote
name = AliceAlice💡💡 Naming rules: Variable names can contain letters, numbers, and underscores. They must start with a letter or underscore (not a number). Use descriptive names like
instead ofuser_age.x
main.pySandbox
main.py
Ctrl + Enter