|
|
|
 |
 |
 |
|
Guessing Game
|
|
|  |
by Rodney Hoffman Occidental College Los Angeles, California
 |
|
|  |
More Nifty Assignments...
Assignment
Have your program pick a random integer between 1 and 100 (and keep it "to itself"). When you run the program, you try to guess the number. The program tells you whether your guess is too high, too low, or exactly right. If you don't guess the number within a certain number of tries, the program should tell you that you lost the game and tell you what the hidden number was. Be sure the program gives good instructions when it begins.
Teacher's Comments
If you want to give your students more of a challenge, try the following add-on later in the course.
Binary Search
Redo the "guess the number from 1 to 100" game with the roles reversed. This time, the person playing the game thinks of a number, and your program tries to guess it. Give good and complete instructions and prompts.
Contribute
If you would like to contribute your suggestions for nifty assignments, please submit your ideas.
|
|
|
|
|
|