| Home | Code/Games | About me |
|---|
a python executable to play rock paper scissors.
download
The code:
from random import randint
print("Rock, Paper, Scissors, SHOOT!\n\n----------------------------")
rps = """
* * * * * * * * * * * *
* * * * *
* * * * * * * * * * * *
* * * * *
* * * *
* * * * * * *
"""
print(rps)
def game():
motions = ["null", "rock", "paper", "scissors"]
computer = randint(1, 3)
player = int(input("\nrock = 1, paper = 2, scissors = 3: "))
if (player == 1 and computer == 3) or (player == 2 and computer == 1) or (player == 3 and computer == 2):
results(player, computer, motions, "you win!")
elif (player == 1 and computer == 2) or (player == 2 and computer == 3) or (player == 3 and computer == 1):
results(player, computer, motions, "you lose")
else:
results(player, computer, motions, "it's a tie")
def results(player, computer, motions, line):
print("you picked: {}".format(motions[player]))
print("the computer picked: {}".format(motions[computer]))
print(line)
running = True
while running:
game()
again = str(input("\nplay again? (y/n) "))
if again == "y":
running = True
elif again == "n":
running = False
end = input("press enter to exit")