mithiancoding

Challenges

Read it, trace it, fix it

Most of programming is reading code: your own, other people's, and code that doesn't work yet. These sets practise exactly that. Each one fits after a unit of the course, but you can try any of them whenever you like.

10 sets 14 trace tables 29 bug hunts 66 challenges in all

Trace tables

Run the code in your head, line by line, and write down every variable as it changes. The answers come from running the code for real.

Bug hunts

Each program has one mistake. Run it, compare what it does with what it should do, and click the line that's wrong.

Break it down

Split a problem into small functions, write them one at a time, then put them together.

01

First programs

Follow variables as they change, and find the mistakes in short programs that use print and input.

2 trace tables3 bug hunts1 prediction1 question

Best after Unit 5: Input and conversion 13 min
02

Decisions

Work out which branch runs, and fix if statements that take the wrong path.

2 trace tables3 bug hunts1 prediction1 question

Best after Unit 6: Making decisions 14 min
03

Loops

Trace loops one pass at a time, and fix loops that run once too often, or not enough.

2 trace tables3 bug hunts1 prediction1 puzzle

Best after Unit 8: For loops 18 min
04

Lists

Watch lists grow and change, and track down the classic list mistakes.

2 trace tables3 bug hunts1 prediction1 question

Best after Unit 9: Lists 14 min
05

Functions

Follow values in and out of functions, and fix the mistakes people make with return.

1 trace table3 bug hunts1 exercise1 prediction

Best after Unit 10: Functions 16 min
06

Strings, dictionaries and sets

Trace a dictionary as it fills up, and catch the bugs that come from strings that never change.

2 trace tables3 bug hunts1 prediction1 question

Best after Unit 14: Sets 14 min
07

Break it down

Split a problem into small functions, write each one, then put them together.

1 bug hunt3 exercises1 puzzle1 question

Best after Unit 20: Problem solving and debugging 23 min
08

Classes and objects

Follow an object's attributes as its methods run, and fix the mistakes that come with self.

1 trace table3 bug hunts2 predictions

Best after Unit 22: Inheritance and special methods 11 min
09

Algorithms

Trace a binary search step by step, and fix recursion and sorting code that goes wrong at the edges.

1 trace table3 bug hunts1 prediction1 question

Best after Unit 25: Sorting algorithms 13 min
10

Advanced Python

The bugs that catch out experienced programmers, from default values to generators and decorators.

1 trace table4 bug hunts1 prediction1 question

Best after Unit 36: Dynamic programming 14 min