Leerpad
Alle reeksen in deze cursusHow a computer turns input into output, and what makes a set of instructions an algorithm. No code yet: this chapter sets up the vocabulary the rest of the course uses.
| Status | Status | Type | Titel |
|---|---|---|---|
| Computers and programs | |||
| Algorithms |
Printing text to the screen with print, and the syntax rules that make it work. Four Make exercises build the same joke program under increasingly tight constraints.
| Status | Status | Type | Titel |
|---|---|---|---|
| Output | |||
| Predict, run and investigate | |||
| Modify | |||
| Make | |||
| Make with one print | |||
| Make with a delay | |||
| Make with blank lines |
Arithmetic operators and casting between text and numbers, so a program can calculate with its input instead of only echoing it.
| Status | Status | Type | Titel |
|---|---|---|---|
| Arithmetic operators | |||
| Casting | |||
| Predict and run | |||
| Investigate | |||
| Modify | |||
| Make | |||
| Make a perimeter calculator | |||
| Make a volume and surface calculator | |||
| Make a tip calculator |
Chaining conditions with elif so a program can choose between more than two options, and why the order of the branches decides the outcome.
| Status | Status | Type | Titel |
|---|---|---|---|
| Selection with ELIF | |||
| Predict and run | |||
| Investigate | |||
| Modify | |||
| Make a room finder | |||
| Make the insult-o-matic | |||
| Make a time reminder |
Repeating code a set number of times with for loops and range. Count controlled iteration: the number of repetitions is known before the loop starts.
| Status | Status | Type | Titel |
|---|---|---|---|
| For loops | |||
| The range function | |||
| Predict and run | |||
| Investigate | |||
| Modify | |||
| Modify with even numbers | |||
| Make | |||
| Make a repeater | |||
| Make a total |
Letting the computer pick: random whole numbers with randint and randrange, a random item from a list with choice, and games built on them.
| Status | Status | Type | Titel |
|---|---|---|---|
| The randint function | |||
| The choice function | |||
| The randrange function | |||
| Predict and run | |||
| Investigate | |||
| Modify | |||
| Modify with repeated guesses | |||
| Modify with playing cards | |||
| Make | |||
| Make with close guesses |
Working with text: its length, upper and lower case, cutting out substrings with slicing, looping through the characters, and converting to and from ASCII codes.
| Status | Status | Type | Titel |
|---|---|---|---|
| Length and case | |||
| Substrings | |||
| Looping through a string | |||
| ASCII codes | |||
| Predict and run | |||
| Modify | |||
| Modify with ASCII codes | |||
| Make | |||
| Make a vowel counter | |||
| Make initials |
Data with rows and columns, stored as a list of lists: reading and changing one item with two indices, and visiting every item with nested loops.
| Status | Status | Type | Titel |
|---|---|---|---|
| 2D arrays | |||
| Looping through a 2D array | |||
| Predict and run | |||
| Investigate | |||
| Modify | |||
| Modify with step counts | |||
| Make | |||
| Make with averages |
Saving data from a program into a text file: write mode replaces what was there, append mode adds to the end, and every line ends with a newline.
| Status | Status | Type | Titel |
|---|---|---|---|
| Writing to a file | |||
| Appending to a file | |||
| Predict and run | |||
| Investigate | |||
| Modify | |||
| Modify with the grade on one line | |||
| Modify with validation | |||
| Make | |||
| Make a results file |