Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Commit e262d3f

Browse files
Update Rock_paper_scissor.py
1 parent 2dc148e commit e262d3f

File tree

1 file changed

+41
-12
lines changed

1 file changed

+41
-12
lines changed

Basic-Scripts/Rock_paper_scissor.py

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
@author: Gulshan
66
"""
7-
7+
# Function rock_paper_scissor--->
88
def rock_paper_scissor(num1,num2,bit1,bit2):
99
p1=int(num1[bit1])%3
1010
p2=int(num2[bit2])%3
@@ -22,14 +22,43 @@ def rock_paper_scissor(num1,num2,bit1,bit2):
2222
print("Player two wins!!")
2323
elif(player_one[p1]=="Scissor" and player_two[p2]=="Paper"):
2424
print("Player one wins!!")
25-
player_one={0:'Rock',1:'Paper',2:'Scissor'}
26-
player_two={0:'Paper',1:'Rock',2:'Scissor'}
27-
while(1):
28-
num1=input("Player one, Enter your choice")
29-
num2=input("Player two, Enter your choice")
30-
bit1=int(input("Player one, Enter the secret bit position"))
31-
bit2=int(input("Player two, Enter the secret bit position"))
32-
rock_paper_scissor(num1,num2,bit1,bit2)
33-
ch=input("Do you want to continue? y/n")
34-
if(ch=='n'):
35-
break
25+
26+
# Main Function To Execute Rock Paper Scissor
27+
if __name__ == '__main__':
28+
player_one={0:'Rock',1:'Paper',2:'Scissor'}
29+
player_two={0:'Paper',1:'Rock',2:'Scissor'}
30+
while(1):
31+
num1=input("Player one, Enter your choice ")
32+
num2=input("Player two, Enter your choice ")
33+
bit1=int(input("Player one, Enter the secret bit position "))
34+
bit2=int(input("Player two, Enter the secret bit position "))
35+
rock_paper_scissor(num1,num2,bit1,bit2)
36+
ch=input("Do you want to continue? y/n ")
37+
if(ch=='n'):
38+
break
39+
40+
41+
'''
42+
Output Implementation:
43+
44+
Player one, Enter your choice 123
45+
Player two, Enter your choice 567
46+
Player one, Enter the secret bit position 0
47+
Player two, Enter the secret bit position 1
48+
Draw
49+
50+
Do you want to continue? y/n y
51+
Player one, Enter your choice 012
52+
Player two, Enter your choice 234
53+
Player one, Enter the secret bit position 1
54+
Player two, Enter the secret bit position 2
55+
Player one wins!!
56+
57+
Do you want to continue? y/n y
58+
Player one, Enter your choice 345
59+
Player two, Enter your choice 012
60+
Player one, Enter the secret bit position 0
61+
Player two, Enter the secret bit position 2
62+
Player one wins!!
63+
64+
'''

0 commit comments

Comments
 (0)