TORONTO KIDS COMPUTER CLUB | PMCA Sunday 12:00 Python Homework 20.10.18.
18502
post-template-default,single,single-post,postid-18502,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

PMCA Sunday 12:00 Python Homework 20.10.18.

22 Oct PMCA Sunday 12:00 Python Homework 20.10.18.

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.

No Comments

Sorry, the comment form is closed at this time.