StarvardStarvard

Starvard University · Python

Python 101

The most useful programming language to learn first. Write real programs, automate boring work, and stop being afraid of code.

Starvard University
Starvard University
Python 101 · Starvard University

The whole course in brief

Twelve lessons, distilled. Read this and you are already thinking like a programmer.

  1. Python reads like English. It was designed for humans first. That is why it is the best first language.
  2. Your first program takes five minutes. Install, type one line, run it. The mystique dies fast, and that is the point.
  3. Variables are labeled boxes. Put a value in, give it a name, use the name later. That is most of programming.
  4. If statements are decisions. Code that reacts to conditions is code that does useful things.
  5. Loops do the boring work for you. Doing something 10,000 times is one line in Python. That is the superpower.
  6. Functions are reusable recipes. Write it once, name it, call it forever.
  7. Errors are teachers, not verdicts. Read the last line of the error message. It usually tells you exactly what is wrong.
  8. Lists and dictionaries hold your data. Almost every real program is just moving these two containers around.
  9. Libraries mean you never start from zero. Thousands of free toolkits do the hard parts. You assemble them.
  10. Automate one annoying task. Renaming files, scraping a page, cleaning a spreadsheet: pick one and kill it.
  11. Read code more than you write it. Stealing patterns from good code is how everyone learns.
  12. Build something real in week two. Tutorials teach syntax. Projects teach programming.

All you need is a computer. Python is free, and everything in this course works on Mac, Windows, or Linux.

The twelve lessons

Lesson 1

Why Python First

There are hundreds of programming languages, and most beginners pick by anxiety. Here is the simple answer: learn Python first. It reads closer to English than any other serious language, it runs everywhere, and it is used for everything from websites to data science to AI. When you learn your second language later, Python will have taught you how to think.

The practical case is even stronger. Python has the largest collection of free libraries in the world, which means whatever you want to build, someone has already built half of it and given it away. You are not learning a language so much as joining the biggest tool-sharing community on earth.

One more thing: Python is forgiving. It does not make you declare variable types or manage memory or end every line with a semicolon. It lets you focus on the logic, which is the actual skill. The fussy details can come later, with language number two.

Python first, everything else later. Learn to think in code with the friendliest teacher available.

Lesson 2

Your First Program in Five Minutes

Go to python.org, download Python, install it. Open a terminal and type python3. You are now talking to Python directly. Type this and press enter:

print("Hello, world")

It prints Hello, world. Congratulations, you are a programmer. That was not a trick. Real programs are just longer versions of this moment: you tell the computer what to do, in a language strict enough that it understands you.

A laptop with a glowing code window and a green checkmark

Next, save that line in a file called hello.py and run it with python3 hello.py. Same result, but now the program lives in a file you can grow. Every programmer on earth started exactly here. The gap between this and a real application is just reps.

Five minutes to programmer. Install it, print something, run a file. The mystique is gone.

Lesson 3

Variables: Labeled Boxes

A variable is a box with a name on it. You put a value inside and use the name whenever you need it:

name = "Dave"
age = 35
print("Hi", name, "you are", age)

That is genuinely most of programming: storing values under names and using them later. The computer remembers so you do not have to. Names should say what the thing is. total_price beats x every time, and your future self will thank you at 2am when you are debugging.

Variables can change. score = 0 becomes score = 10 after the player scores. This is why they are called variables. Constants, values that never change like a tax rate, get ALL_CAPS names by convention, a small courtesy that makes code readable.

Names are for humans. The computer does not care; your future self does.

Lesson 4

If Statements: Code That Decides

Programs get interesting when they react. An if statement checks a condition and does something only when it is true:

temperature = 102
if temperature > 100:
    print("Fever. Call the doctor.")
else:
    print("All good.")

Notice the indentation. Python uses spacing instead of brackets to show what belongs inside the if. It looks odd for a day and then feels obvious forever. The condition can use == (exactly equal), != (not equal), >, <, and combinations with and, or, and not.

Every app you use is built from these decisions stacked thousands deep. Login checks, recommendations, game rules, form validation: all if statements at heart. Learn this one idea well and you understand a shocking amount of software.

Conditions turn scripts into programs. If this, then that: the atom of all software.

Lesson 5

Loops: The Superpower

A loop repeats something without you typing it again. This is the moment programming stops being a novelty and starts being a superpower:

for name in ["Ana", "Ben", "Cy"]:
    print("Hello,", name)

Three names, three greetings, one block of code. Now imagine 10,000 names. Same code. A human would take days and make mistakes. Python takes a blink and makes none. Any task that is "do this boring thing many times" is a task Python was born to kill.

A robot arm pressing a button that starts gears turning automatically

There is also the while loop, which repeats until a condition changes, perfect for things like "keep asking until the user types a valid answer." Between for and while, you can express almost any repetition you will ever need.

One line replaces 10,000 keystrokes. Repetition is the job; loops are the employee.

Lesson 6

Functions: Reusable Recipes

A function packages steps under a name so you can run them anytime with one line:

def greet(name):
    return "Hello, " + name

print(greet("Dave"))

You define it once with def, then call it a hundred times. When the greeting needs to change, you change it in one place. This is how programs stay manageable as they grow: small named pieces, each doing one job, snapped together.

Good functions are short and do one thing. If you cannot describe what a function does in one sentence, split it. You will write hundreds of these, and the habit of small functions is what separates code that survives from code that collapses under its own weight.

Write once, call forever. Functions turn repetition into reuse.

Lesson 7

Errors Are Teachers

Your code will break. Constantly. Professionals write broken code all day; they are just fast at fixing it. The error message is your guide, and the secret is to read the last line first. That is where Python tells you what actually went wrong, in plain-ish English.

The greatest hits: NameError means you used a name you never defined, usually a typo. TypeError means you mixed types, like adding a number to text. IndentationError means your spacing is off. SyntaxError means Python could not even parse the line, often a missing quote or parenthesis just above where it points.

When stuck, do three things: read the last line of the error, check the line it names, and paste the error into a search engine. Someone has had your exact error before, and the answer is waiting. Debugging is not a talent. It is a procedure.

Read the last line first. The error message is instructions, not insults.

Lesson 8

Lists and Dictionaries

Real programs juggle data, and Python gives you two containers that handle almost everything. A list is an ordered collection:

groceries = ["eggs", "milk", "bread"]
groceries.append("coffee")
print(groceries[0])

A dictionary stores pairs of labels and values, like a real dictionary stores words and definitions:

person = {"name": "Dave", "city": "Denver"}
print(person["city"])

A detective finding a glowing bug among code on a screen

Almost every program you will ever write is some version of: get data into lists and dictionaries, loop over them, make decisions with if statements, put results somewhere. Master these two containers and the rest is vocabulary.

Lists for order, dictionaries for labels. Two containers run the world.

Lesson 9

Libraries: Never Start From Zero

A library is code someone else wrote, tested, and gave away. Need to download web pages? There is a library. Analyze data? Library. Send emails, make charts, read PDFs, talk to AI? Libraries, all of them. Installing one is a single command:

pip install requests

Then you import it and use it like it was always part of Python. This is the real reason Python dominates: the ecosystem. You are standing on the shoulders of millions of programmers, and the view is excellent.

The skill to build here is searching well. "Python library to read Excel files" will find you the answer in seconds. Read the library's examples before its documentation. Copy a working example, then modify it toward your goal. Everyone does this. It is not cheating; it is the workflow.

Search, install, assemble. Half of programming is knowing what already exists.

Lesson 10

Automate One Annoying Task

Theory ends here. Pick one boring task from your actual life: renaming 200 photos, pulling numbers out of a spreadsheet, checking a website for changes, organizing downloads. Something you do by hand and resent. That resentment is fuel.

Break it into tiny steps and automate one step at a time. Renaming files? First, write code that lists the files. Then code that computes the new names. Then code that renames them. Test each step before adding the next. Small wins compound into a working tool, usually in an afternoon.

Your first automation will save you maybe twenty minutes a month. That is not the point. The point is the proof: you bent the computer to your will. The second automation goes faster, the third faster still, and soon you see automatable tasks everywhere.

One annoying task, one afternoon. Automation is a habit, not a project.

Lesson 11

Read Code Like a Book

Beginners write code. Intermediates read it. Reading other people's code teaches you patterns no tutorial covers: how functions get organized, how errors get handled, how a real project is shaped. Find a small open-source project in an area you like and read it like a book, top to bottom, asking "why did they do it this way?"

A person holding a glowing toolbox of automation tools

When you find a trick you like, steal it. Programmers call this "learning from the codebase" and it is the entire profession's continuing education. Keep a snippet file of patterns you admire. Your own code will absorb them by osmosis.

Also: read your own old code. Code you wrote three months ago will look like a stranger wrote it, sometimes badly. That embarrassment is the feeling of getting better. Celebrate it.

Steal patterns, not code. Reading good code is the fastest way to write good code.

Lesson 12

Build Something Real

Tutorials have a trap: you can follow along forever and still not be able to start from a blank file. The cure is a project with no guide. Pick something small and slightly too hard: a to-do app, a budget tracker, a bot that texts you the weather, a game of tic-tac-toe.

You will get stuck. That is the curriculum. Getting unstuck, by searching, reading errors, and asking for help, is the actual skill programming pays for. A finished ugly project teaches ten times more than a perfect tutorial.

Starvard's only homework: start the project this week. Blank file, real goal, no tutorial.

Graduation

You Can Code Now

You can install Python, store values, make decisions, loop ten thousand times, package logic into functions, read errors, juggle data, install libraries, automate a boring task, read other people's code, and start a real project. That is not "intro to programming." That is programming. The rest is practice and vocabulary, and you now know how to get both.

Keep going: Data Analysis 101 to put your Python to work on numbers, AI Prompting 101 for your new coding copilot, and all free Starvard courses.

Get certified

Prove you know it. Earn your Python 101 certificate.

10 questions. Score 7 or more. $5, yours forever.

Take the quiz

Back to Starvard University

Keep learning

This course is part of Starvard University, striving for greatness.

Explore Starvard · All free courses