py
The friendly one
Python
Variables, loops, functions, lists and dicts. The language that reads almost like English and runs half the internet's scripts.
0 / 14 lessons done
- 01 Your first line of PythonWrite and run your first Python program with print(). Learn what a string is, why quotes matter and how Python runs your code top to bottom. 2 exercises
- 02 Variables are name tagsLearn how Python variables work: assignment with =, naming rules, reassigning values and why a variable is a name tag, not a box. 2 exercises
- 03 Numbers and arithmeticPython arithmetic explained: + - * /, floor division //, remainder %, powers **, int vs float, and why 0.1 + 0.2 is not exactly 0.3. 2 exercises
- 04 Strings, slices and f-stringsWork with text in Python: indexing from 0, negative indexes, slicing, len(), string methods like upper() and replace(), and f-strings. 2 exercises
- 05 input() and type conversionRead user input in Python with input(), and convert it with int(), float() and str(). Learn why "5" + "5" is "55" and how to fix it. 2 exercises
- 06 Making decisions with ifPython if, elif and else explained with comparison operators, and/or/not, indentation rules and the = vs == mix-up beginners always hit. 2 exercises
- 07 Repeating with whileLearn Python while loops: how the condition is checked each time, how to avoid infinite loops, and when to use break to stop early. 2 exercises
- 08 for loops and range()Python for loops explained: looping over strings, range(stop), range(start, stop, step), the off-by-one rule and building up a total. 2 exercises
- 09 Lists hold many thingsPython lists for beginners: creating, indexing, append, remove, len, looping, sorted vs sort, and why two names can share one list. 2 exercises
- 10 Functions, and return vs printWrite your own Python functions with def, parameters and return. Learn the difference between return and print, and why None shows up. 2 exercises
- 11 Dictionaries map keys to valuesPython dictionaries explained: keys and values, adding and updating, get() with a default, looping with items(), and counting things. 2 exercises
- 12 Reading errors and debuggingHow to read a Python traceback, what SyntaxError, NameError, TypeError and IndexError mean, and a calm process for finding and fixing bugs. 2 exercises
- 13 Handling errors with try and exceptCatch errors in Python with try and except, so bad input does not crash your program. Learn which errors to catch, else, finally and when not to bother. 2 exercises
- 14 Classes: make your own typesPython classes for beginners. Bundle data and the functions that use it into one object with class, __init__, self and methods, with a game character example. 2 exercises
Projects for this track
FreePython · 30 min
Number guesser
The computer picks a number, you guess, it says higher or lower. Loops, if/else and input() in one tiny game.
- Pick a secret number with
random.randint(1, 100). - Read guesses from
input()in a while loop. - Print "higher" or "lower" until the guess is right, then print how many tries it took.
FreePython · 25 min
Grade report
Turn a pile of test scores into a tidy report: everyone's mark, the class average and who came top. Dictionaries and loops doing real work.
- Loop over the
marksdictionary with.items()and print each name and score. - Work out the class average and print it with one decimal place.
- Find the student with the highest mark without using
max(), then try it withmax()and compare.
Pro, coming soonPython · 3 hours
Text adventure engine
Rooms as dictionaries, an inventory as a list, and a game loop that parses commands. Build the engine, then write your own story.
Get told when it opens