Beginners Programming Course

This is the homepage for a beginners programming course I'm teaching in Python.

We're working through Automate the Boring Stuff with Python.

I've also written up some slides to accompany the book.

And I've created some flashcards as well. Download & install Anki to use these flashcards.

Questions

  1. Write a program that uses a while loop to print out all the integers from 5 to 40 inclusive.
    1. Rewrite the program to use a for loop instead.
  2. Write a program to ask the user for 2 integers, then print out all the integers between the 2 supplied integers inclusive.
    1. Improve this program by checking the user's input and making sure that the first integer is smaller than or equal to the second one.
  3. Write a program that asks the user for 2 integers, then checks if the total of the 2 integers is 34. If it is, the user is told that they have guessed correctly. If not, they have to keep guessing.
    1. Improve this program by telling the user whether the total of their 2 numbers is too high or too low.
    2. Improve this program by giving the user a maximum of 10 attempts, telling the user when they guess incorrectly how many attempts they have left.
    3. Improve this program by changing 34 to be a user-supplied integer ie the user supplies a target total at the beginning of the program. However, this will make it too easy for the user, as they'll know what the total is, so scramble the user-supplied integer by: adding 50, then multiplying it by 30, then modulo it by 50, then add 5. So, for example, if the user supplies 4, then when scrambled this will give 25, and if the user supplies 5, then when scrambled this will give 5.