12 Mar PMCA Sunday 18:00 Python Homework 20.03.08.
Question 1:
Write a program that does the following:
- Generates a random secret number between 1 and 100 (including 1 and 100).
- Asks the user to guess the secret number, then tell them whether they guessed too low, too high, or exactly right.
- Keeps the game going until user guesses the secret number unless the user types “quit”
- Keeps track of how many guesses the user has taken, and when the game ends, prints this out.
- Make sure you use comments so that you, other students, and the teacher can easily understand your code.
Execute the Game: test output player chooses to play until guessing secret
Sample output 1:
Welcome to the number guessing game:
> To play, enter a guess between 1 to 100.
> To quit, enter the word ‘quit’.
What is your guess: 50
Your guess is too high. Guess a lower number.
What is your guess: 30
Your guess is too low. Guess a higher number.
What is your guess: 40
Your guess is too high. Guess a lower number.
What is your guess: 35
Your guess is too low. Guess a higher number.
What is your guess: 37
You guessed the secret number!
It takes you 5 tries.
Sorry, the comment form is closed at this time.