Beginner Fundamentals
Variables
A variable is a name pointing to a value. In Python you don’t declare the type: just assign.
name = "Ana"
age = 30
Dynamic typing
The type comes from the value and can change:
x = 5 # int
x = "text" # now str
Naming rules
- Start with a letter or
_, never a number. - Only letters, numbers, and
_. - Case sensitive:
age≠Age. - Convention:
snake_casefor variables.
my_age = 25 # good
2name = "x" # error
Multiple assignment
a, b, c = 1, 2, 3
x = y = z = 0
Print values
name = "Ana"
print(name)
print("Name:", name)