Python Basics & Variables
BeginnerPython's simple syntax makes it perfect for learning programming. Let's start with variables and data types.
Concept Overview
Python uses dynamic typing—you don't need to declare variable types. The interpreter figures it out based on the assigned value.
# Variables and data types
name = "Hexworth" # str
age = 25 # int
gpa = 3.85 # float
is_enrolled = True # bool
# Type checking
print(type(name)) # <class 'str'>
print(type(age)) # <class 'int'>
Tasks
- Create variables for: your name, birth year, and whether you like Python
- Calculate your age from your birth year and store it
- Use
type()to verify each variable's data type - Print all variables with descriptive labels
- Experiment with arithmetic operators (+, -, *, /, //, %, **)
Hint
Use 2025 - birth_year to calculate age. For exponents, 2 ** 3 equals 8.
Related Visualizers
Reflection
How does Python's dynamic typing compare to languages you've used before?