-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrock_paper_scissor.py
executable file
·73 lines (64 loc) · 1.79 KB
/
rock_paper_scissor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python3
__author__ = "Jugal Kishore & Akash Shiva"
__version__ = "1.0"
import random
import subprocess
import os
def clear():
# For Windows
if os.name == "nt":
_ = subprocess.call("cls")
# For anything else (Linux, etc)
else:
_ = subprocess.call("/usr/bin/clear")
while True:
print("///Rock Paper Scissor Game///")
print("")
print("1. for Rock")
print("2. for Paper")
print("3. for Scissor")
print("4. to exit")
print("")
print("Enter your choice:")
total = ["Rock", "Paper", "Scissor"]
try:
human_put = int(input()) - 1
except ValueError:
print("")
print("Not an integer")
break
comp_put = random.randint(0, 2)
if human_put == 0:
choice = "Rock"
elif human_put == 1:
choice = "Paper"
elif human_put == 2:
choice = "Scissor"
elif human_put == 3:
print("Bye Bye")
break
else:
print("")
print("Available Choices are: 1, 2, 3, 4")
print("")
print("Press any key to continue...")
input()
clear()
continue
print("")
print("Your Choice: ", choice)
print("")
print("Computer Choice: ", total[comp_put])
print("")
if human_put == comp_put:
print("It's a Tie")
elif ((human_put == 0 and comp_put == 1) or (human_put == 1 and comp_put == 2) or (human_put == 2 and comp_put == 0)):
print("You Lost!")
elif ((comp_put == 0 and human_put == 1) or (comp_put == 1 and human_put == 2) or (comp_put == 2 and human_put == 0)):
print("You Won!")
print("")
print("Press any key to continue...")
input()
clear()
print("\nCreated by Jugal Kishore & Akash Shiva -- 2020")
# Run it online at https://python.jugalkishore.repl.run/