Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is the code of part 3A that\'s mentioned to be imported def Guess_Win(): pr

ID: 3672076 • Letter: T

Question

This is the code of part 3A that's mentioned to be imported

def Guess_Win():
print('Try to guess a number between 1 and 10')
guess = input('What''s your first guess? ')
from random import randint
num = randint(1, 10)
while(guess != num):
if guess < num:
print('Too low!')
else:
print('Too high!')
guess = input('What''s your next guess? ')
print('That''s it!')

Guess_Win()

Write a Python script (that is the user interface) which first display a menu to the user and allows user to play the game or quit from the program according to the user response. After each round of the game, this menu to play again, or quit. must be displayed again and the user can choose whether Guess Win Allows user to guess a random number between 1 and 10. A sample interaction when the script is run must look like follows. D Play the guessing gane Quit Enter your choice:p try to guess a number between i and 10 What's your first guess?5 Too lo What's your next guess79 Too high What's your next guess?6 That's it #MENU## Pl Play the guessing gane Quit Enter your cheice P Try to guess a number between i and 10 What's your first guasa75 Too low What's your next guess79 That's it pl play the guessing game Quit Enter your choice:q Bye!! Save your script as "PA2 Question3B.py" Note: Import Guess Win () function from PA2-Ouestion3A.py Steps of user interface can be given as follows: 1. Display the menu 2. Get user choice 3. while user choice is not equals to “q" do, a. Allow use to play the game by calling the GuesssWin function b. Display the men c. Get user choice 4. Display nessage Bye!!! * You can write a separate function to display the menu. (optional)

Explanation / Answer

#If raw_input is not working then please use input()
def Guess_Win():
    print('Try to guess a number between 1 and 10')
    guess = input('What''s your first guess? ')
    from random import randint
    num = randint(1, 10)
    while(guess != num):
        if guess < num:
            print('Too low!')
        else:
            print('Too high!')
        guess = input('What''s your next guess? ')
    print('That''s it!')

if __name__ == "__main__":

   ch = 'p'
   while(True):
       print "###MENU###"
       print "p) Play the guessing game"
       print "q) Quit"
       ch = raw_input("Enter you choice: ")
       if(ch!='p' and ch!='q'):
           print "Wrong choice entered. Try again"
           continue
       elif ch=='q':
           print "Bye!!!"
           break
       else:
           Guess_Win()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote