TORONTO KIDS COMPUTER CLUB | Aurora Saturday 16:30 Python Homework 20.04.04.
17319
post-template-default,single,single-post,postid-17319,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.8.0,vc_responsive

Aurora Saturday 16:30 Python Homework 20.04.04.

09 Apr Aurora Saturday 16:30 Python Homework 20.04.04.

Question 1:
Write a program for a movie theater using while loop. It will keep asking your age and display the ticket price, until you enter “quit”. It is free if you are less than 3 years old, otherwise if your age is less than 16 years old or over 65 years old the ticket is $10, otherwise the price is $15.

Sample:
How old are you? 10
$10
How old are you? 2
Free
How old are you? 50
$15
How old are you? 67
$10
How old are you? quit


Question 2:

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.