Advertisement
Guest User

rps by beb

a guest
Oct 18th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.59 KB | None | 0 0
  1. #how the computer chooses their play
  2. import random
  3. comp = random.randint(1,3)
  4.  
  5.  
  6.  
  7. #Ask the user to play
  8. def intro():
  9.     print("Welcome to Rock, Paper, Scissor! Please choose your weapon:")
  10.     print("1. Rock")
  11.    
  12.     print("2. Paper")
  13.     print("3. Scissor")
  14. intro()
  15.  
  16. #Ask them if they want to play again - look in game()
  17. def again():
  18.     print("Do you want to play again?(Y/N)")
  19.     play = input()
  20.     play = play.lower()
  21.     if play == "y" or play == "yes":
  22.         intro()
  23.         game()
  24.     elif play == "n" or play == "no" :
  25.         print("Bye")
  26.     else:
  27.         print("Please type either Y or N")
  28.         again()
  29.  
  30. #results
  31. compw = "==> Computer wins!"
  32. userw = "==> User wins!"
  33. draw = "==> Draw!"
  34.  
  35. #The actual game
  36. def game():
  37.     print("", end='\n\n')
  38.     print("Your weapon: ", end="")
  39.     user = input()
  40.     user = user.lower()
  41.     choice = ["rock","paper","scissor"]#the player's set of choice
  42.  
  43.     #check the user's input
  44.     if user.isalpha() == True and user in choice:
  45.         print("You have chosen",user,"!")
  46.        
  47.         #Computer choose rock
  48.         if comp == 1:
  49.             print("Computer chose rock!")
  50.             if user == "rock":
  51.                 print("Rock VS Rock", end='\n\n')
  52.                 print(draw)
  53.             if user == "paper":
  54.                 print("Rock VS Paper", end='\n\n')
  55.                 print(userw)
  56.             if user == "scissor":
  57.                 print("Rock VS Scissor", end='\n\n')
  58.                 print(compw)
  59.             again()
  60.  
  61.         #Computer choose paper
  62.         elif comp == 2:
  63.             print("Computer chose paper!")
  64.             if user == "rock":
  65.                 print("Paper VS Rock", end='\n\n')
  66.                 print(compw)
  67.             if user == "paper":
  68.                 print("Rock VS Paper", end='\n\n')
  69.                 print(draw)
  70.             if user == "scissor":
  71.                 print("Rock VS Scissor", end='\n\n')
  72.                 print(userw)
  73.             again()
  74.  
  75.         #Computer choose scissor
  76.         elif comp == 3:
  77.             print("Computer chose scissor!")
  78.             if user == "rock":
  79.                 print("Scissor VS Rock", end='\n\n')
  80.                 print(userw)
  81.             if user == "paper":
  82.                 print("Scissor VS Paper", end='\n\n')
  83.                 print(compw)
  84.             if user == "scissor":
  85.                 print("Scissor VS Scissor", end='\n\n')
  86.                 print(draw)
  87.             again()
  88.     else: #for when they input incorrectly
  89.         print("Invalid input. Please type one of these words: Rock, Paper, Scissor")
  90.         game()
  91. game()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement