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 numguess.pyYou need to ask the user to pick a number from through and store it in a variable named MyChoice. 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: numbergenIt should RETURN a random integer 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 guesscheckIt needs to be defined with taking two 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 keepgoing Boolean statusIf the guessed number is lower than the generated random # output print the user has guessed too low and return a True "keepgoing" statusIf the guessed number is higher than the generated random # output print the user has guessed too high and return a True "keepgoing" statusNote: No use of break command allowed in code in order to receive any credit.Another Hint: Your return Boolean from the guesscheck function can update the keepgoing Boolean in your main, so that it exits after correctly guessing the number! ie: keepgoing guesscheckMyChoice, randomnumberA 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 BEGIN!!Please enter your guess: is too low. Please guess again!!Please enter your guess: is too high. Please guess again!!Please enter your guess: You guessed correctly, congratulations. It only took you guesses!!!Goodbye
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
