4
4
5
5
@author: Gulshan
6
6
"""
7
-
7
+ # Function rock_paper_scissor--->
8
8
def rock_paper_scissor (num1 ,num2 ,bit1 ,bit2 ):
9
9
p1 = int (num1 [bit1 ])% 3
10
10
p2 = int (num2 [bit2 ])% 3
@@ -22,14 +22,43 @@ def rock_paper_scissor(num1,num2,bit1,bit2):
22
22
print ("Player two wins!!" )
23
23
elif (player_one [p1 ]== "Scissor" and player_two [p2 ]== "Paper" ):
24
24
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