Last active
June 27, 2017 01:01
-
-
Save mrspucches/38ba20b957ae3269d0251ba625c1e55e to your computer and use it in GitHub Desktop.
Rock, Paper, Scissors against computer
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
import random | |
# Author: Dominic Spucches | |
# Project: Rock, Paper, Scissors game with computer. | |
# Date Started: 6/26/2017 | |
print('Hello and welcome to a game of Rock, Paper, Scissors. You will play against a computer, if you wish to continue press 1 if not press 2.') | |
inp = int(input('> ')) | |
while True: | |
if inp == int(1): | |
print('Ok so you want to play! You have three choices... of course. Rock, Paper, or Scissors.') | |
game = ('rock', 'paper', 'scissors') | |
user = input('> ') | |
computer = random.choice(game) # Makes a random choice from the array game | |
print('The computer chose', computer) | |
if user == 'rock' and computer == 'rock': | |
print('TIE!') | |
elif user == 'paper' and computer == 'paper': | |
print('TIE!') | |
elif user == 'scissors' and computer == 'scissors': | |
print('TIE!') | |
elif user == 'paper' and computer == 'rock': | |
print('Paper beats rock! You win!') | |
elif user == 'scissors' and computer == 'paper': | |
print('Scissors beats paper! You win!') | |
elif user == 'rock' and computer == 'scissors': | |
print('Rock beats scissors! You win!') | |
else: | |
print('You lost, but the computer wins!') | |
print("Do you want to play again? Type 1 to play again or type 2 to quit.") | |
play_again = input('> ') | |
if play_again == '1': | |
print('Lets play again!') | |
else: | |
print('Ok! Sad to see you go! Come back again next time!') | |
quit() | |
else: | |
print('Thank you for playing!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment