Question: Build a simple number guessing game using functions in Python and name the file num _ guess.pyYou need to ask the user to pick a

Build a simple number guessing game using functions in Python and name the file num_guess.pyYou need to ask the user to pick a number from 1 through 50 and store it in a variable named My_Choice. You will need to track the total number of guesses made. This will require you to define and initialize a variable to track the total. You will also need to incorporate a LOOP within your main function to continue to ask for guesses until the user guesses correctly. Write the two required function definitions detailed below, in addition to a main function with the following requirements:Function one should be named: number_genIt should RETURN a random integer (1-50) in your main function to use as a parameter in the other function. No parameters need to be included for this particular function definition. Hint: You will need to import the random library at the top of your program. Make sure the random number is generated only ONCE for each game played! Function two should be named guess_checkIt needs to be defined with taking two (2) parameters:The users current guessThe generated random numberWithin this function, check for the following conditions:If the number is guessed correctly, output (print) the user has guessed correctly and return an False keep_going Boolean statusIf the guessed number is lower than the generated random #, output (print) the user has guessed too low and return a True "keep_going" statusIf the guessed number is higher than the generated random #, output (print) the user has guessed too high and return a True "keep_going" statusNote: No use of break command allowed in code in order to receive any credit.Another Hint: Your return Boolean from the guess_check function can update the keep_going Boolean in your main, so that it exits after correctly guessing the number! ie: keep_going = guess_check(My_Choice, random_number)A successful run should resemble the following:Welcome to Jordan's Number Guessing Game!!The objective is to correctly guess the "magic" number with the fewest attempts possible!It is a randomly generated number in the range of 1-50. BEGIN!!Please enter your guess: 1010 is too low. Please guess again!!Please enter your guess: 1818 is too high. Please guess again!!Please enter your guess: 14You guessed correctly, congratulations. It only took you *3* guesses!!!Goodbye

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!