Courses/Streamlit: 20 Real Apps/Module 1: Setup & Python Survival Kit
Module 1 · Lesson 345 minBeginner

Python Crash Course — The 20% You Need

Lesson goal
Learn variables, lists, dictionaries, loops, and functions — everything the projects use, in one focused lesson.

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:

code
name = "Galvan"
age = 21
height = 5.9
is_coder = True

print(name, age, height, is_coder)

Output:

code
Galvan 21 5.9 True

Four 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

code
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 variables

f-strings are the modern way to build text: put an f before the quotes and wrap variables in curly braces.

3. Lists — ordered collections

code
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 end

4. Dictionaries — labeled storage

A dictionary stores values attached to keys, like a real dictionary maps words to meanings:

code
student = {
    "name": "Aarav",
    "age": 16,
    "language": "Python"
}

print(student["name"])          # Aarav
student["age"] = 17             # update
student["grade"] = "10th"       # add new key

You will use dictionaries constantly — every API response on the internet is basically a dictionary.

5. Conditions — making decisions

code
marks = 85

if marks >= 90:
    print("Grade: A")
elif marks >= 75:
    print("Grade: B")
else:
    print("Keep practicing!")

Output:

code
Grade: B

Notice 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

code
# 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 - 1

7. Functions — reusable blocks

code
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

code
age = input("Your age: ")     # input() ALWAYS returns a string
print(age + 1)                # TypeError: can't add str and int

Fix:

code
age = int(input("Your age: "))
print(age + 1)                # works

input() 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:

code
python crash.py

Change 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.

Checkpoint
You can write a function that takes a list and returns a filtered dict without looking anything up.
What you learned
  • Variables, types, and f-strings
  • Lists and dictionaries — the workhorses
  • Loops and functions