Advertisement
Guest User

python

a guest
Oct 1st, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. #Noah Cabral
  2.  
  3.  
  4. from random import randint
  5. userWin= 0 # user win total
  6. compWin = 0 #computer win total
  7. tie = 0 #tie total
  8.  
  9. print ("Hello! Welcome to rock, paper, scissors!")
  10. print ("The objective is simple, you and the computer each choose either rock, paper, or scissors")
  11. print ("The winner is determined by these standards: Rock beats scissors, scissors beat paper, and paper beats rock!")
  12. while True :
  13. print ("")
  14. choice = input ("Please choose rock, paper, or scissors") #gets users choice
  15. computer = randint (1,3) #generates computers choice
  16. userNum = 0 #value of users guess
  17.  
  18.  
  19. #sets computers value where 1 = rock, 2 = paper, 3 = scissors
  20. print ("")
  21. if computer == 1:
  22. print ("The computer chooses rock")
  23. elif computer == 2:
  24. print ("The computer chooses paper")
  25. elif computer == 3:
  26. print ("The computer chooses scissors")
  27.  
  28. #sets users value where 1= rock, 2 = paper, 3 = scissors
  29. print ("")
  30. if choice == "rock" :
  31. userNum = userNum + 1
  32. elif choice == "paper":
  33. userNum = userNum + 2
  34. elif choice == "scissors":
  35. userNum = userNum + 3
  36.  
  37.  
  38. #deteremins outcome
  39. if userNum == 1 and computer == 3:
  40. print ("Your rock crushes the computer's scissors!")
  41. userWin = userWin + 1
  42. elif userNum == 2 and computer == 1 :
  43. print ("Your paper covers the computer's rock!")
  44. userWin = userWin + 1
  45. elif userNum == 3 and computer == 2:
  46. print ("Your scissors cut the computer's paper!")
  47. userWin = userWin + 1
  48. elif computer == 1 and userNum == 3:
  49. print ("The computer's rock crushes your scissors!")
  50. compWin = compWin + 1
  51. elif computer == 2 and userNum == 1:
  52. print ("The computer's paper covers your rock!")
  53. compWin = compWin + 1
  54. elif computer == 3 and userNum == 2:
  55. print ("The computer's scissors cut your paper!")
  56. compWin = compWin + 1
  57.  
  58. else :
  59. print ("Its a tie!")
  60. tie = tie + 1
  61. print ("")
  62. end = input("Would you like to keep playing?")
  63. if end == "no" :
  64. break
  65.  
  66.  
  67.  
  68.  
  69.  
  70. print ("")
  71. print ("You had",userWin,"wins")
  72. print ("")
  73. print ("The computer had",compWin,"wins")
  74. print ("")
  75. print ("There was",tie,"ties")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement