Python in one lesson
Everything in this course is built with Python, so let's cover the 20% of the language you'll use 95% of the time. You don't need to memorize this — come back and reference it whenever something looks unfamiliar.
1. Variables — boxes with names
A variable stores a value so you can use it later:
name = "Galvan"
age = 21
height = 5.9
is_coder = True
print(name, age, height, is_coder)Output:
Galvan 21 5.9 TrueFour values, four types: string (text in quotes), int (whole number), float (decimal), bool (True/False). Python figures out the type automatically — you never declare it.
2. Strings — text with superpowers
first = "Tech"
full = first + " With Galvan" # joining with +
print(full.upper()) # TECH WITH GALVAN
print(len(full)) # 16 — counts characters
print(f"Welcome to {full}!") # f-strings insert variablesf-strings are the modern way to build text: put an f before the quotes and wrap variables in curly braces.
3. Lists — ordered collections
languages = ["Python", "JavaScript", "C++"]
print(languages[0]) # Python — counting starts at 0!
languages.append("Go") # add to the end
print(len(languages)) # 4
print(languages[-1]) # Go — negative counts from the end4. Dictionaries — labeled storage
A dictionary stores values attached to keys, like a real dictionary maps words to meanings:
student = {
"name": "Aarav",
"age": 16,
"language": "Python"
}
print(student["name"]) # Aarav
student["age"] = 17 # update
student["grade"] = "10th" # add new keyYou will use dictionaries constantly — every API response on the internet is basically a dictionary.
5. Conditions — making decisions
marks = 85
if marks >= 90:
print("Grade: A")
elif marks >= 75:
print("Grade: B")
else:
print("Keep practicing!")Output:
Grade: BNotice the colon and the indentation — Python uses 4 spaces to know which lines belong inside the if. Indentation is not decoration in Python; it *is* the structure.
6. Loops — repetition
# Loop over a list
for lang in ["Python", "Go", "Rust"]:
print(f"I am learning {lang}")
# Repeat a fixed number of times
for i in range(3):
print("Iteration", i)
# Loop while a condition is true
count = 3
while count > 0:
print(count)
count = count - 17. Functions — reusable blocks
def greet(name):
return f"Hello, {name}!"
message = greet("Galvan")
print(message) # Hello, Galvan!Define once with def, call it as many times as you want, and return sends a value back to whoever called it.
8. The one error you must understand
age = input("Your age: ") # input() ALWAYS returns a string
print(age + 1) # TypeError: can't add str and intFix:
age = int(input("Your age: "))
print(age + 1) # worksinput() gives you text, always. Convert it with int() or float() before doing math. You will forget this at least once — everyone does.
✅ Checkpoint
You don't complete this lesson by reading — you complete it by typing. Run every snippet above in a file called crash.py:
python crash.pyChange values. Break things. Fix them. When every snippet has run from *your* keyboard, you're ready — the next lesson puts your first web app on screen.