Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Programming Challenge ( 1 0 points ) Write a Python program, number _ guess.py , to play a guessing game. The program should generate a
Programming Challenge points
Write a Python program, numberguess.py to play a guessing game. The program should generate a random number between and inclusive. Then, the program should ask the user to guess the number. If the user's guess is higher than the random number, the program should display "Too high, try again." If the user's guess is lower than the random number, the program should display "Too low, try again." If the user's guess is equal to the random number, the program should display "You got it in tries.", where is the number of guesses the user took to get to the right number.
Your program should use at least three functions: main, picknumber, and respond, where the functions have these responsibilities:
main: main should control the operation of the program, calling picknumber and respond as needed. main should also keep track of the count of the user's tries to guess the number.
main should finally print the number of tries the user needed to guess the number.
picknumber: picknumber should use random to choose a number between LOWEST and HIGHEST inclusive, where LOWEST and HIGHEST are global constants defined near the top of the program. picknumber should return the chosen number to main.
respond: respond should take number and guess as parameters where number is the value chosen by the program and guess is the number chosen by the user. respond should print the appropriate message, either "Too high, try again." or "Too low, try again.".
Here a sample output from the program:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started