I design my exercises so most participants should be able to do them by themselves. And I encourage them to talk to me if they can’t. I also check in with them one on one.
The range of exercises depends on the level of the course. The more advanced the course, the more I expect the participants to be able and willing to work by themselves.
My Introduction to Programming course is designed for absolute beginners. Although I also get people on the course who have some experience already.
To make this course work for everyone each chapter has exercises at four different levels. I encourage participants to select themselves the right level.
Level 1: Existing code
For beginners writing code can be intimidating. There is so much to get right before anything happens.
Exercises at this level come with working code. The task is to review the code, try to understand it, predict what it will do and run it. And to make some small changes and see what effect this has.
# TODO: Read the code.
# What do you think the output will be
# Enter your guess here:
# TODO: Run the code.
# What is the actual output
# Enter it here:
# TODO: Did you guess right?
# If so, well done :-)
# If not, look at the code again and try to understand it
# If anything isn't clear, ask the trainer to explain
# TODO: Spend some time (once or multiple times)
# Adding or changing some code
# then guessing the output, running the code and changing it
Level 2: Fix incorrect code
This level consist of code which is documented line by line. The task is to read each comment and the associated code and see if the code does what the comment suggests. If the code doesn’t match the comment, change the code. Finally, run the code and compare the actual output against the expected output.
Can you spot the error in this code?
# TODO: Read through the comments below, carefully
# All the comments are correct, but some of the code is not
# Correct the code, so it does exactly what the comment above it says
# TODO: Run the code again
# The output should now exactly match the expected output (see above)
# If it does, congratulations, you have fixed all the errors
# If not, repeat the previous step, i.e. look for and correct the remaining errors
# Ask for a number, using the prompt
number = input(prompt)
# Convert the number (from a string) to an integer
number = int(lowest_number)
Level 3: Write code, line by line
At this level, the participant gets to write the code themselves, from scratch, line by line. They are given a series of comments, and have to write a line of code for each comment. This lets them work on getting syntax right without having to think too much about the bigger picture.
# Set the smallest (possible value) to 1
# Set the largest (possible value) to 20
# Show: Think of a number from (smallest) to (largest)
# Show: And I will try to guess it
Level 4: Write code from requirements
At the highest level, participants work from a description of what to create. This is more challenging, and requires a deeper understanding of the course materials.
# Time to write code from scratch. Good luck
# and remember to ask the trainer for support when you get stuck
# TODO: Write code which does the following:
# Go through the numbers from 1 to 20
# If it is divisible by 3, say 'Fizz'
# Divisible by 5, say 'Buzz'
# Divisible by 3 and by 5, say 'FizzBuzz'
# Otherwise, say the number
# Remember, to test if something is divisible by two: number % 2 == 0
Some participants need more time to practice than we can fit in, and may struggle to keep up. I encourage everyone to work at their own speed, which may include continuing working on an exercise from a previous chapter.
And they can of course use the course materials as reference, ask me if they get stuck or have a look at the suggested solution.