Created
September 27, 2016 09:44
-
-
Save pinkpretty/e648c67ba012fc09d0fb963b0a249acc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
this is the 8th exercise of practice python | |
''' | |
''' | |
Make a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays (using input), compare them, print out a message of congratulations to the winner, and ask if the players want to start a new game) | |
Remember the rules: | |
•Rock beats scissors | |
•Scissors beats paper | |
•Paper beats rock | |
''' | |
''' | |
Rock paper scissor game | |
''' | |
''' | |
You can play with computer or 2 players | |
''' | |
import random | |
print("\t\t Rock Paper Scissor\t\t") | |
computerChoice = ['rock','paper','scissor'] | |
def play(input1,input2): | |
if (input1 == input2 ): | |
print("Both are equal ! Try Again") | |
elif((input1 == 'rock') and (input2 == 'paper')): | |
print("player 2 won!") | |
elif((input1 == 'paper') and (input2 == 'rock')): | |
print("player 1 won!") | |
elif(input1 == 'scissor' and input2 == 'rock'): | |
print("Player 2 won!") | |
elif(input1 == 'rock' and input2 == 'scissor'): | |
print("Player 1 won!") | |
elif(input1 == 'paper' and input2 == 'scissor'): | |
print("Player 2 won!") | |
elif(input1 == 'scissor' and input2 == 'paper'): | |
print("Player 1 won!") | |
elif(input1 == 'rock' and input2 == 'scissor'): | |
print("Player 1 won!") | |
elif(input1 == 'scissor' and input2 == 'rock'): | |
print("player 2 won!") | |
else: | |
print("end") | |
print("Player 1 - input") | |
choice = int(input("Do you want to play with computer or with player?\n Press 1 for computer\n press 2 for player")) | |
if(choice == 2): | |
inp1 = input("Enter rock or paper or scissor - player 1") | |
inp1.upper() | |
print("Player 2 - input") | |
inp2 = input("Enter rock or paper or scissor - player 2") | |
inp2.upper() | |
play(inp1,inp2) | |
elif(choice == 1): | |
print("player 1 is computer") | |
compChoice = random.choice(computerChoice) | |
inp3 = input("Enter rock or paper or scissor - player 2") | |
inp3.upper() | |
play(compChoice,inp3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment