PYTHON 101
python-101 · v1.0.0
ivyx✓
Learn Python from your first print statement to reading and writing files, with a tutor that asks you to predict before you run.
What this course is for
By the end of this course you can read a Python program, say what it will do before you run it, and write one from scratch that takes input, decides, repeats, and saves its result to a file.
What you will be able to do
- Read a traceback and say which line caused it and why
- Choose between a list, a tuple, a set and a dictionary for a given job
- Write a function that takes parameters and returns a value
- Keep a program alive when the person using it types the wrong thing
- Read and write a text file
Who it is for
People writing their first lines of code, and anyone who has copied Python before without reading it
Before you start
- No programming experience
- A computer where you can open this course
Lesson path
How this course works, taught on itself
- 1Working with the tutor15 min
Predict before running, and climb the hint ladder instead of hunting for the answer
Print something, keep it in a variable, take it from a person
- 2Your first program25 min
Print text, comment your code, and read the error Python gives you
- 3Variables and data types30 min
Store a value, ask what type it is, and convert between types
- 4Reading input25 min
Take a value from a person, convert it, and put it in a sentence
Compute a result, then let the program choose what to do with it
- 5Operators30 min
Use arithmetic, comparison and logical operators and know which runs first
- 6Making decisions40 min
Branch with if, elif and else, and order the branches so they cannot overlap
Text, lists, and the three collections that are not lists
- 7Working with text35 min
Index, slice and clean a string without changing the original
- 8Lists35 min
Build a list, change it in place, and know which methods return nothing
- 9Tuples, sets and dictionaries35 min
Say which of the four collections a job needs, and defend the choice
Stop repeating yourself, twice over
- 10Loops45 min
Walk a collection with for, repeat with while, and never write a loop that cannot end
- 11Functions45 min
Define a function with parameters, return a value, and keep its variables to itself
Survive bad input, and remember something after the program ends
- 12Handling errors30 min
Tell the three kinds of error apart and catch the one you can recover from
- 13Reading and writing files30 min
Write text to a file, read it back, and pick the right mode
About this course
PYTHON 101
Thirteen lessons that take you from your first print() to a program that reads
input, decides, repeats, catches its own mistakes, and saves the result to a
file. No prior programming experience is assumed and nothing needs installing.
Every lesson runs on the Python standard library.
How this course teaches
Most courses show you code and ask you to run it. This one asks you what the code will do before you run it, then puts your answer and the real output side by side. That gap is where the learning happens, so the run button on those cells stays shut until you have written a prediction down. Being wrong costs you nothing and teaches you more than being right.
When you get stuck, help arrives in four steps rather than all at once:
| Step | What it gives you | When it opens |
|---|---|---|
| Nudge | Where to look | Straight away |
| Concept | The rule this cell is about | Straight away |
| Steps | What to do, in order | After one attempt |
| Solution | Why your version fails, explained in words | After two attempts |
The last step never hands over the code. It explains the fix and leaves the typing to you, because the typing is the part that sticks.
Some cells run a check after they pass. A cell can print the right number for the wrong reason, and that check is what catches it.
The first lesson teaches all of this on itself, using a cell nobody could get wrong. Fifteen minutes there makes the other twelve lessons work properly.
What you will be able to do
- Read a traceback and say which line caused it and why
- Choose between a list, a tuple, a set and a dictionary for a given job
- Write a function that takes parameters and returns a value
- Keep a program alive when the person using it types the wrong thing
- Read and write a text file
The lessons
Before you start 0. Working with the tutor
Getting started
- Your first program
- Variables and data types
- Reading input
Arithmetic and decisions 4. Operators 5. Making decisions
Data structures 6. Working with text 7. Lists 8. Tuples, sets and dictionaries
Repetition and abstraction 9. Loops 10. Functions
Robustness 11. Handling errors 12. Reading and writing files
One honest note about input()
Lesson 3 is about taking a value from a person. A notebook kernel cannot pause
and wait for someone to type, so that lesson defines a stand-in input() that
replays answers set at the top of the cell. Everything you learn there holds
exactly as written in a .py file you run in a terminal, where input() really
does wait for the keyboard. The lesson says so on screen rather than pretending
otherwise.
Progress
Your progress is stored in your workspace and never written back into the lesson files. You can share a lesson, reset a course, or hand the folder to someone else without carrying your answers along with it.