Answered step by step
Verified Expert Solution
Link Copied!

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 (10 points)
Write a Python program, number_guess.py, to play a guessing game. The program should generate a random number between 1 and 100 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 x tries.", where x is the number of guesses the user took to get to the right number.
Your program should use at least three functions: main, pick_number, and respond, where the functions have these responsibilities:
main: main should control the operation of the program, calling pick_number 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.
pick_number: pick_number 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. pick_number 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:
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Technology

Authors: Suad Alagic

1st Edition

354096276X, 978-3540962762

More Books

Students also viewed these Databases questions

Question

recognise typical interviewer errors and explain how to avoid them

Answered: 1 week ago

Question

identify and evaluate a range of recruitment and selection methods

Answered: 1 week ago

Question

understand the role of competencies and a competency framework

Answered: 1 week ago