Exercise: Number guessing game
- Every level must include all the features from all the lower levels as well.
Level 0
- Create a file called number_guessing_game_0.py
- Using the random module the computer "thinks" about a whole number between 1 and 20.
- The user has to guess the number. After the user types in the guess the computer tells if this was bigger or smaller than the number it generated, or if was the same.
- The game ends after just one guess.
Level 1
- Create a file called number_guessing_game_1.py
- The user can guess several times. The game ends when the user guessed the right number.
Level 2
- Create a file called number_guessing_game_2.py
- If the user hits 'x', we leave the game without guessing the number.
Level 3
- Create a file called number_guessing_game_3.py
- If the user presses 's', show the hidden value (cheat)
Level 4
- Create a file called number_guessing_game_4.py
- Soon we'll have a level in which the hidden value changes after each guess. In order to make that mode easier to track and debug, first we would like to have a "debug mode".
- If the user presses 'd' the game gets into "debug mode": the system starts to show the current number to guess every time, just before asking the user for new input.
- Pressing 'd' again turns off debug mode. (It is a toggle each press on 'd' changes the value to to the other possible value.)
Level 5
- Create a file called number_guessing_game_5.py
- The 'm' button is another toggle. It is called 'move mode'. When it is 'on', the hidden number changes a little bit after every step (+/-2). That is, it is chaning by one of the following: -2, -1, 0, 1, 2. Pressing 'm' again will turn this feature off.
Level 6
- Create a file called number_guessing_game_6.py
- Let the user play several games.
- Pressing 'n' will skip this game and start a new one. Generates a new number to guess.