Title / Description
Code print("Code to play games 'cut and o' or 'stone paper and scissors") print("press 4 to play 'cut and o' or 5 to play 'stone paper and scissors") opt=int(input('Enter the game numberr you want ot play:')) if opt==4: print('You have decided to play "cut and o"') p=0 print("""Press 'A' if you want to play with a player else press 'Z' in to play with computer""") inp=input('Enter the option to be seleected:') n1=input("Enter The Name Of The 1st Player :") n2=input("Enter The Name Of The 2nd Player :") print("Choose The Character For",n1,"\nPress 1 For X and press 2 for O :") ch=int(input()) if ch==1: p1="X" p2="O" else: p1="O" p2="X" print(n1,"Will Play With",p1,"\n",n2,"Will Play With",p2,"\n\n\n") aa="\t1\t2\t3"#coordinate of blanks print(aa) a=list("\n\n1\t_\t_\t_\n\n\n2\t_\t_\t_\n\n\n3\t_\t_\t_")#/n and /t are single elements d={(1,1):4,(2,1):6,(3,1):8,(1,2):14,(2,2):16, (3,2):18,(1,3):24,(2,3):26,(3,3):28} for i in a: print(i,end="") print("\n\n\nFill The Box By Choosing The Correct set Of Coordinates") for i in range(10): print("\n\nTurn Of",n1,) x=int(input("Enter The x coordinate (1,2,3) :")) y=int(input("Enter The Y coordinate (1,2,3) :")) a[d[(x,y)]]=p1 p=p+1 print(aa) for i in a: print(i,end="") print("\n\nTurn Of",n2,) if a[4]==a[6]==a[8]==p1 or a[14]==a[16]==a[18]==p1 or a[24]==a[26]==a[28]==p1 or a[4]==a[14]==a[24]==p1 or a[6]==a[16]==a[26]==p1 or a[8]==a[18]==a[28]==p1 or a[4]==a[16]==a[28]==p1 or a[8]==a[16]==a[24]==p1: if p%2==1: print(n1,"\n\nHas Won The Game Congratulations !!!!") break x=int(input("Enter The x coordinate (1,2,3) :")) y=int(input("Enter The Y coordinate (1,2,3) :")) a[d[(x,y)]]=p2 p=p+1 print(aa) for i in a: print(i,end="") if a[4]==a[6]==a[8]==p2 or a[14]==a[16]==a[18]==p2 or a[24]==a[26]==a[28]==p2 or a[4]==a[14]==a[24]==p2 or a[6]==a[16]==a[26]==p2 or a[8]==a[18]==a[28]==p2 or a[4]==a[16]==a[28]==p2 or a[8]==a[16]==a[24]==p2: if p%2==0: print(n2,"\n\nHas Won The Game Congratulations !!!!") break #code to play stone paper and scissors elif opt==5: #code print('''The code is for stone paper scissors game if u give same as the player 2 then the game will continue and all rules of the game''') tup='STONE','PAPER','SCISSORS' while True: import random as r player2=r.randint(0,2) option2=tup[player2] option1=input("Enter the option:") if option1.upper() not in tup: print("The value is not defined") break else: print("Value entered from player 2:",option2) if option1.upper()=="ROCK" and option2 == 'SCISSORS': print("You won !") break elif option1.upper()=="PAPER" and option2=='STONE': print("You won !") break elif option1.upper()=="SCISSORS" and option2=='PAPER': print("You won !") break
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code