TORONTO KIDS COMPUTER CLUB | Sunday 9:45 Python Homework 11.11.
15948
post-template-default,single,single-post,postid-15948,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

Sunday 9:45 Python Homework 11.11.

13 Nov Sunday 9:45 Python Homework 11.11.

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.

(The student who completes the program correctly with all the requirements above will have their program featured in class when we review the homework !!!)

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.