Skip to content

Latest commit

 

History

History
executable file
·
46 lines (38 loc) · 2.39 KB

week-01-part-3-exercises.md

File metadata and controls

executable file
·
46 lines (38 loc) · 2.39 KB

Week 1 Exercises

Practice exercises

Work through the following exercises of the book Learn Python the hard way by Zed Shaw (book is best read online):

  • Exercise 2
  • Exercise 3
  • Exercise 4
  • Exercise 5
  • Exercise 6
  • Exercise 29
  • Exercise 30

Tips:

  • You should run these exercises non-interactively (i.e. as a Python program)! To run a Python program, open the environment using the terminal, navigate to the folder where your FILENAME.py file is located (which you have created and edited using a text editor like Visual Studio Code) and execute it using the command python FILENAME.py (replacing 'FILENAME' with the actual name of the file).
  • Note that in all of these exercises, the author gives you the code to run. Rather than copy pasting this code onto your text editor, the author and I strongly encourage you to type the program yourself in order to get practice writing Python code.
  • If you're new to Python (and perhaps coding in general), try to do as many exercises as you can (given your time availability). There's quite a few exercises on the list above but, like learning a new spoken language, significant practice is required to develop a strong foundation. Otherwise, if you already have prior experience with Python, then you may already be familiar with most of these concepts (if so please feel free to skip).
  • Each exercise has a "Study drills" section which I also recommend going through if you've got time.

Self-assessment challenge

Implement the "Number guessing game" program specified in Chapter 8 of A Beginner Guide to Python 3 Programming by John Hunt, and do the exercise specified in Section 8.7:

Add the following additional features to the game:

  1. Provide a cheat mode, for example if the user enters −1 print out the number they need to guess and then loop again. This does not count as one of their goes.
  2. If their guess is within 1 of the actual number tell the player this.
  3. At the end of the game, before printing 'Game Over', modify your program so that it asks the user if they want to play again; if they say yes then restart the whole thing.