Hello everyone thanks in advance for solving my program. I have written a guessing ga

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bhumika
    New Member
    • Jan 2021
    • 1

    Hello everyone thanks in advance for solving my program. I have written a guessing ga

    import random

    def levels():
    menu = ' '
    while(menu != "X" or menu != "x"):
    print("........ ......GUESSING GAME........... .")
    print("........ ............... ............... .")
    print("(1) Numbers from 1 to 20")
    print("(2) Numbers from 21 to 100")
    print("(X) Exit")
    print("........ ............... ............... .")
    menu=input("Ent er a choice:")
    if(menu=="1"):
    guess=comparisi on
    elif(menu=="2") :
    guess=comparisi on1
    elif(menu=="X" or menu =="x"):
    print("Exit chosen")
    else:
    print("Invalid choice")
    return menu
    def input_function( ):
    guess=int(input ("Enter your guess:"))
    return guess

    def random_function ():
    random_number=r andom.randint(1 ,20)
    return random_number

    def random_function 1():
    random_number1= random.randint( 21,100)
    return random_number1

    def comparision(gue ss,random_numbe r):
    if(guess<random _number):
    print("sorry,gu ess again your guess is too low")
    elif(guess>rand om_number):
    print("sorry,gu ess again your guess is too high")
    else:
    print("Yay,cong rats.You have guessed correctly.")

    def comparision1(gu ess,random_numb er1):
    if(guess<random _number1):
    print("sorry,gu ess again your guess is too low")
    elif(guess>rand om_number1):
    print("sorry,gu ess again your guess is too high")
    else:
    print("Yay,cong rats.You have guessed correctly.")
    level=levels()
    guess=input_fun ction()
    random_number=r andom_function( )
    random_number1= random_function 1()
  • dev7060
    Recognized Expert Contributor
    • Mar 2017
    • 656

    #2
    What's the question?

    Comment

    Working...