Lesson 3 of 60 · python
Python Refresher: Variables, Data Types, and Control Flow
Duration: 20 minutes
Python Refresher
Even if you already know Python, a quick recap helps set the stage for data‑science‑specific code.
Variables and Data Types
# Numbers
x = 10 # int
y = 3.14 # float
# Strings
name = "Alice"
# Booleans
is_valid = True
# Collections
my_list = [1, 2, 3]
my_tuple = (1, 2, 3)
my_dict = {"id": 1, "value": 42}
Control Flow
# If‑else
if x > 5:
print("big")
else:
print("small")
# Loops
for i in range(5):
print(i)
while x > 0:
x -= 1
List comprehensions (the data‑science favorite)
squares = [i**2 for i in range(10)]