Guest User

Untitled

a guest
Mar 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. def ex8():
  2.  
  3. import random
  4.  
  5. option = -1
  6. print("Welcome to an exciting game of rock, paper and scissors. \n0.Exit\n1. Rock\n2.Papper\n3.Scissors")
  7.  
  8. while(option != 0):
  9. option = int(input(("Please enter your option: ")))
  10. if((type(option)!= int) or (option < 0 or option > 3)):
  11. print("Invalid option!")
  12. machine = random.randint(1,3)
  13.  
  14. if(option == 1):
  15. if(machine == 1):
  16. print("Draw!")
  17. elif(machine == 2):
  18. print("You lost! Paper beats rock!")
  19. elif(machine == 3):
  20. print("You win! Rock beats scissors!")
  21. elif(option == 2):
  22. if(machine == 1):
  23. print("You win! Papper beats rock!")
  24. elif(machine == 2):
  25. print("Draw!")
  26. elif(machine == 3):
  27. print("You lose! Scissors beat paper!")
  28. elif(option == 3):
  29. if(machine == 1):
  30. print("You lose! Rock beats scissors!")
  31. elif(machine == 2):
  32. print("You win! Scissors beat paper")
  33. elif(machine == 3):
  34. print("Draw!")
  35. elif(option == 0):
  36. print("See you next time!")
Add Comment
Please, Sign In to add comment