Python for Marion Coders : Lesson Set 3, Week 8

Please complete homework for Weeks 6 and 7 (Lesson sets 1 and 2 ) before doing this lesson (or be daring and dive in)

This lesson set shows how to use the "if" statement and how to generate random numbers in Python.

Lesson 10 : Video : Use of If statement in Idle Shell

Lesson 11:  Video : Use of If statement in program file
                    Python program created in video

Lesson 12:  Video : Generating random numbers in Python
                    Python program created in video

Lesson 13:  Video:  Outline of how to create a guessing game using random numbers
                    Text file with outline of how to create a guessing game using random numbers
                    Completed program outlined in video.  Try coding the program on your own before looking at this solution.

Homework: The primary assignment is to create the guessing game program outlined in lesson 13. This is challenging. I suggest that you try to code it without looking at the solution.   When you get stuck, look at the completed program to solve that problem and then go back to coding. The idea is to write as much of the program on your own as possible. Use the completed program to help you find what is needed, but don't copy code from that program and paste it in yours. Type each line in your program.

The game asks the user to guess a number between 1 and 100. ( You could change this to any range - say 1 and 1000). The program will tell users if their guess is too high or too low.   To make the game easier (especially if they are guessing a number between 1 and 1000), you could modify the program to tell them when they are "way to high" or "way to low".    For example, if their guess was more than 30 greater than the correct answer the program could display ("Your number is WAY too high").

Also, you could put the program in a loop and ask the user if they want to play again each time they complete a game.