-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
88 lines (88 loc) · 3.83 KB
/
app.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#constructing stone paper scissors......
#import random for random outcomes from the computer
import random
points_count = 0
#creating a definition
def mainpoints(cg : str, yg : str, lwd: str):
print(F"The computers guess was {guess_emojised[cg]}, you your guess was {yg}, you {lwd} as point")
def subpoints(points: int):
print(F"The current points you scored is {points}")
#creating a infinite loops to make the user play as much as he wants to and end the game whenever required
while True:
#assigning the value to choose between randomly by the computer
low = 1
max = 3
computer_guess = random.randint(low, max)
#test version of computers guess
guess_available = {1: "scissors",
2: "paper",
3: "stone"}
#emoji version of computers guess
guess_emojised = {"scissors": "scissors",
"paper": "paper",
"stone": "stone"}
#available answers
available_answers = ["scissors", "paper", "stone"]
#to check the points and produce them as a output alsoknown as prestatement for while loops
while True:
try:
manual_answer = str(input("please input a guess between stone, paper or scissors and 'end' to quit game : ")).casefold()
break
except (EOFError, KeyboardInterrupt):
print()
print("please give a valid input")
if manual_answer == "end":
print(F"the total points you scored was {points_count}")
break
elif manual_answer in available_answers:
#for scissors
if manual_answer == "scissors":
if guess_available[computer_guess] == "scissors":
mainpoints("scissors", "scissors", "drew")
points_count += 0#drawn
subpoints(points_count)
elif guess_available[computer_guess] == "stone":
mainpoints("stone", "scissors", "lost")
points_count -= 1#lost
subpoints(points_count)
elif guess_available[computer_guess] == "paper":
mainpoints("paper", "scissors", "won")
points_count += 1#won
subpoints(points_count)
else:
print("Oops!!, something went wrong")
#for stone
elif manual_answer == "stone":
if guess_available[computer_guess] == "scissors":
mainpoints("scissors", "stone", "won")
points_count += 1#won
subpoints(points_count)
elif guess_available[computer_guess] == "stone":
mainpoints("stone", "stone", "drew")
points_count += 0#drawn
subpoints(points_count)
elif guess_available[computer_guess] == "paper":
mainpoints("paper", "stone", "lost")
points_count -= 1#lost
subpoints(points_count)
else:
print("Oops!!, something went wrong")
#for paper
if manual_answer == "paper":
if guess_available[computer_guess] == "scissors":
mainpoints("scissors", "paper", "lost")
points_count -= 1#lost
subpoints(points_count)
elif guess_available[computer_guess] == "stone":
mainpoints("stone", "paper", "won")
points_count += 1#won
subpoints(points_count)
elif guess_available[computer_guess] == "paper":
mainpoints("paper", "paper", "drew")
points_count += 0#drawn
subpoints(points_count)
else:
print("Oops!!, something went wrong")
else:
print("please give a valid input")
#The End!!! Thankyou#