Skip to content

Commit 53c0cdc

Browse files
Added Stone, Paper, Scissor in python
1 parent 174cc10 commit 53c0cdc

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed
Loading
Loading
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import random
2+
list=["s","p","sc"]
3+
choice = random.choice(list)
4+
5+
print("s for stone\n")
6+
print("p for paper\n")
7+
print("sc for scicors\n")
8+
print("choose any one from this\n")
9+
10+
user_point = 0
11+
computer_point = 0
12+
13+
number_of_attempts = 1
14+
while (number_of_attempts < 11) :
15+
choice = random.choice(list)
16+
a=str(input())
17+
if (a == "s" and choice == "p") :
18+
print("The computer used paper, so you lost")
19+
20+
elif (a == "s" and choice == "sc") :
21+
print("The computer used scicors, so you win")
22+
23+
elif (a == "p" and choice == "s") :
24+
print("The computer used stone, so you win")
25+
26+
elif (a =="p" and choice == "sc") :
27+
print("The computer used scicors, so you lost")
28+
29+
elif (a == "sc" and choice == "s") :
30+
print("The computer used stone, so you lost")
31+
32+
elif (a == "sc" and choice == "p") :
33+
print("The computer used paper, so you win")
34+
35+
elif(a== choice):
36+
print("You and computer used same")
37+
38+
else :
39+
print("Invalid statement please try again")
40+
exit
41+
42+
number_of_attempts = number_of_attempts + 1
43+
44+
print("Number of attempts remaining",11-number_of_attempts)
45+
46+
if (a == "s" and choice == "sc" or a == "p" and choice == "s" or a == "sc" and choice == "p") :
47+
user_point = user_point + 1
48+
49+
50+
elif(a == "s" and choice == "p" or a =="p" and choice == "sc" or a == "sc" and choice == "s") :
51+
computer_point = computer_point + 1
52+
53+
else :
54+
user_point = user_point
55+
computer_point = computer_point
56+
print(f"Your score is {user_point} and computer score is {computer_point}")
57+
58+
if (user_point > computer_point) :
59+
print("You won the match")
60+
else :
61+
print("You lost the match")
62+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Introduction
2+
If you feel board while you are coding and you feel like playing some kind of game, then this is the best game which will entertain you as well as it gives the memory of your childhood.
3+
4+
## How to install library
5+
pip install random
6+
7+
## How to use
8+
1. You has to install all the library mentioned above.
9+
2. Run this programme in your command prompt or any terminal.
10+
3. The computer will ask input from the user and you has to provide the correct input otherwise it will show that you have enterd wrong input.
11+
4. Computer will make its turn and it will show the result in the screen.
12+
5. In the end it will show the who have won the game and what is the score of winner.
13+
14+
## Output
15+
![](Images/img1.png)
16+
![](Images/img2.png)

0 commit comments

Comments
 (0)