Support our Blind Hand Charity by donating at 9818291723. Your contribution has the potential to bring about significant positive change for humanity.

Search This Blog

Monday, December 18, 2023

ODD AND EVEN GAME

import random as ran

gs=gc=gscw=gsuw=gccw=gcuw=0
o=0
while o!=3:
    print("""Choose the game mode:
[1]. Simple
[2]. Crazy
[3]. Exit""")
    o=int(input("Enter the mode number = "))
    if o==3:
        break
    if o==1 or o==2:
        print("Choose: [1].Even or [2].Odd")
        d=int(input("Enter the decision number = "))
        r=ran.randint(1,10)
        cpt=0
        while cpt!=1:
            ou=int(input("Enter your number = "))
            if ou<11:
                cpt=1
            else:
                print("Incorrect number Entered")
        if d==1:
            print("User\tComputer")
            print("Even\t  Odd  ")
            print('┌───┐\t ┌───┐')
            print(' ',ou,' \t  ',r,' ')
            print('└───┘\t └───┘')
            bu=bc=0
            if (ou+r)%2==0:
                print("You won the toss. Choose [1].Ball or [2].Bat")
                bu=int(input("Enter your decison number = "))
                bc=3-bu
            else:
                print("You Loss the toss")
                bc=ran.randint(1,2)
                bu=3-bc
                if bc==1:
                    print("I choose To ball")
                elif bc==2:
                    print("I choose to Bat")
        elif d==2:
            print("User\tComputer")
            print(" Odd\t  Even ")
            print('┌───┐\t ┌───┐')
            print(' ',ou,' \t  ',r,' ')
            print('└───┘\t └───┘')
            bu=bc=0
            if (ou+r)%2!=0:
                print("You won the toss. Choose [1].Ball or [2].Bat")
                bu=int(input("Enter your decison number = "))
                bc=3-bu
            else:
                print("You Loss the toss")
                bc=ran.randint(1,2)
                bu=3-bc
                if bc==1:
                    print("I choose To ball")
                elif bc==2:
                    print("I choose to Bat")
    if o==1:
        gs+=1
        if bu==2:
            su=pu=0
            print("User Batting Begins")
            while pu!=-1:
                cc=ran.randint(1,10)
                cpt=0
                while cpt!=1:
                    cu=int(input("Enter your number = "))
                    if 0<cu<11:
                        cpt=1
                    else:
                        print("Incorrect number Entered")
                print("User\tComputer")
                print(" Bat\t  Ball  ")
                print('┌───┐\t ┌───┐')
                print(' ',cu,' \t  ',cc,' ')
                print('└───┘\t └───┘')
                if cc==cu:
                    print("You scored",su,'run')
                    su+=1
                    print("Target :",su)
                    pu=-1
                else:
                    su+=cu
                    print('Runs Scored -',su)
            sc=pc=0
            print("Computer Batting Begins")
            while pc!=-1:
                cc=ran.randint(1,10)
                cpt=0
                while cpt!=1:
                    cu=int(input("Enter your number = "))
                    if 0<cu<11:
                        cpt=1
                    else:
                        print("Incorrect number Entered")
                print("User\tComputer")
                print("Ball\t  Bat  ")
                print('┌───┐\t ┌───┐')
                print(' ',cu,' \t  ',cc,' ')
                print('└───┘\t └───┘')
                print('Target -',su)
                if cc==cu:
                    print("You won by",su-sc,'runs')
                    pc=-1
                    gsuw+=1
                elif (sc+cc)>=su:
                    print("Computer Won")
                    pc=-1
                    gscw+=1
                else:
                    sc+=cc
                    print('Runs Scored -',sc)
        if bc==2:
            print("Computer Batting Begins")
            sc=pc=0
            while pc!=-1:
                cc=ran.randint(1,10)
                cpt=0
                while cpt!=1:
                    cu=int(input("Enter your number = "))
                    if 0<cu<11:
                        cpt=1
                    else:
                        print("Incorrect number Entered")
                print("User\tComputer")
                print("Ball\t  Bat  ")
                print('┌───┐\t ┌───┐')
                print(' ',cu,' \t  ',cc,' ')
                print('└───┘\t └───┘')
                if cc==cu:
                    print("Computer scored",sc,'run')
                    sc+=1
                    print("Target :",sc)
                    pc=-1
                else:
                    sc+=cc
                    print('Runs Scored -',sc)
            su=pu=0
            print("User Batting Begins")
            while pu!=-1:
                cc=ran.randint(1,10)
                cpt=0
                while cpt!=1:
                    cu=int(input("Enter your number = "))
                    if 0<cu<11:
                        cpt=1
                    else:
                        print("Incorrect number Entered")
                print("User\tComputer")
                print(" Bat\t  Ball  ")
                print('┌───┐\t ┌───┐')
                print(' ',cu,' \t  ',cc,' ')
                print('└───┘\t └───┘')
                print('Target -',sc)
                if cc==cu:
                    print("Computer won by",sc-su,'runs')
                    pu=-1
                    gscw+=1
                elif (su+cu)>=sc:
                    print("User Won")
                    pu=-1
                    gsuw+=1
                else:
                    su+=cu
                    print('Runs Scored -',su)
    if o==2:
        gc+=1
        if bu==2:
            print("User Batting Begins")
            su=pu=0
            while pu!=-1:
                cc=ran.randint(1,10)
                cpt=0
                while cpt!=1:
                    cu=int(input("Enter your number = "))
                    if 0<cu<11:
                        cpt=1
                    else:
                        print("Incorrect number Entered")
                print("User\tComputer")
                print(" Bat\t  Ball  ")
                print('┌───┐\t ┌───┐')
                print(' ',cu,' \t  ',cc,' ')
                print('└───┘\t └───┘')
                cr==0
                if cc==cu:
                    su+=cc*cu
                    cr=1
                    print('Runs Scored -',su)
                if (cu==cc-1) or (cu==cc+1):
                    print("You scored",su,'run')
                    su+=1
                    print("Target :",su)
                    pu=-1
                    break
                if cr==0:
                    su+=cu
                    print('Runs Scored -',su)
            sc=pc=0
            print("Computer Batting Begins")
            while pc!=-1:
                cc=ran.randint(1,10)
                cpt=0
                while cpt!=1:
                    cu=int(input("Enter your number = "))
                    if 0<cu<11:
                        cpt=1
                    else:
                        print("Incorrect number Entered")
                print("User\tComputer")
                print("Ball\t  Bat  ")
                print('┌───┐\t ┌───┐')
                print(' ',cu,' \t  ',cc,' ')
                print('└───┘\t └───┘')
                print('Target -',su)
                cr=0
                if cc==cu:
                    sc+=cc*cu
                    cr=1
                    print('Runs Scored -',sc)
                if (cc==cu-1) or (cc==cu+1):
                    print("You won by",su-sc,'runs')
                    pc=-1
                    gcuw+=1
                    break
                if sc>=su:
                    print("Computer Won")
                    gccw+=1
                    pc=-1
                    break
                if cr==0:
                    sc+=cc
                    print('Runs Scored -',sc)
        if bc==2:
            sc=pc=0
            print("Computer Batting Begins")
            while pc!=-1:
                cc=ran.randint(1,10)
                cpt=0
                while cpt!=1:
                    cu=int(input("Enter your number = "))
                    if 0<cu<11:
                        cpt=1
                    else:
                        print("Incorrect number Entered")
                cc=cu=0
                print("User\tComputer")
                print("Ball\t  Bat  ")
                print('┌───┐\t ┌───┐')
                print(' ',cu,' \t  ',cc,' ')
                print('└───┘\t └───┘')
                cr=0
                if cc==cu:
                    sc+=cc*cu
                    cr=1
                    print('Runs Scored -',sc)
                if (cc==cu-1) or (cc==cu+1):
                    print("Computer scored",sc,'run')
                    sc+=1
                    print("Target :",sc)
                    pc=-1
                    break
                if cr==0:
                    sc+=cc
                    print('Runs Scored -',sc)
            su=pu=0
            print("User Batting Begins")
            while pu!=-1:
                cc=ran.randint(1,10)
                cpt=0
                while cpt!=1:
                    cu=int(input("Enter your number = "))
                    if 0<cu<11:
                        cpt=1
                    else:
                        print("Incorrect number Entered")
                print("User\tComputer")
                print(" Bat\t  Ball  ")
                print('┌───┐\t ┌───┐')
                print(' ',cu,' \t   ',cc,' ')
                print('└───┘\t └───┘')
                print('Target -',sc)
                cr=0
                if cc==cu:
                    su+=cc*cu
                    cr=1
                    print('Runs Scored -',su)
                if (cu==cc-1) or (cu==cc+1):
                    print("Computer won by",sc-su,'runs')
                    pu=-1
                if su>=sc:
                    print("User Won")
                    pu=-1
                    break
                if cr==0:
                    su+=cu
                    print('Runs Scored -',su)
    print("\n\tSIMPLE")
    print("User -",gsuw)
    print("Computer -",gscw)
    print("\n\tCRAZY")
    print("User -",gcuw)
    print("Computer -",gccw,'\n')

OUTPUT