forked from Aayush-hub/Basic-Python-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrpsg.py
More file actions
66 lines (65 loc) · 2.09 KB
/
Copy pathrpsg.py
File metadata and controls
66 lines (65 loc) · 2.09 KB
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
# Rock,paper and scissor
while(True):
print("Welcome to Rock,paper and scissor Game")
name=input("Enter your name:\n")
print(f"Hi {name},\n We will play Rock,paper and scissor Game for 10 times &\n then, I will tell your score \n So Let the game begin.")
import random
i = 0
z = 0
d=0
l=0
while (i < 10):
o = random.randint(0, 2)
# o=0 is rock, o=1 is paper, o=2 is scissor
x = input("Enter your choice(rock,paper and scissor):\n")
oh = x.lower()
if o == 0 and oh == "rock":
d=d+1
print("It's a draw")
elif o == 1 and oh == "paper":
d = d + 1
print("It's a draw")
elif o == 2 and oh == "scissor":
d = d + 1
print("It's a draw")
elif o == 0 and oh == "paper":
z = z + 1
print("You won this time")
elif o == 0 and oh == "scissor":
l=l+1
print("You lose this time")
elif o == 1 and oh == "rock":
l=l+1
print("You lose this time")
elif o == 1 and oh == "scissor":
z = z + 1
print("You won this time")
elif o == 2 and oh == "rock":
z = z + 1
print("You won this time")
elif o == 2 and oh == "paper":
l=l+1
print("You lose this time")
else:
print("enter a valid choice")
i = i + 1
print(f"you won {z} times,lose {l} time and it was a draw {d} times.")
import time
time=time.asctime(time.localtime(time.time()))
yn=input("Would you like to see scoreboard?\n")
y=yn.lower()
f=open("rockpaperandscissorgame.txt","a")
f.write(f"At {time}, {name} won {z} times,lose {l} time and it was a draw {d} times.\n")
f.close()
if y=="yes":
f=open("rockpaperandscissorgame.txt")
print(f.read())
print("Thank You")
f.close()
else:
print("Thank You \n Hope You will play again")
play1=input("Would you like to play again?:\n")
if play1.lower()=="yes":
pass
else:
break