Diode_exe

Untitled

Jan 16th, 2026
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. import random
  2. user_score = 0
  3. computer_score = 0
  4. POSSIBILITIES = ["paintbrush", "canvas", "palette"]
  5.  
  6. def get_player_name():
  7. user_name = input("Hey there! What's your name? ")
  8. print(f"Whoa! {user_name} is a gorgeous name!")
  9. return user_name
  10.  
  11. def get_player_choice():
  12. # Use input() to ask the user to choose rock, paper, or scissors
  13. user_choice = input("paintbrush, canvas, or palette? ").lower()
  14. # Store their answer in a variable
  15. # Return that variable
  16. if user_choice not in POSSIBILITIES:
  17. print("Sorry, I don't think that's an option. Please try again and check your spelling.")
  18.  
  19. return user_choice
  20. # Replace pass with your code
  21.  
  22. def choose_computer_move():
  23. computer_move = random.choice(POSSIBILITIES)
  24. # Use random.choice(POSSIBILITIES) to pick a random move
  25. # Return that move
  26. return computer_move
  27. # Replace pass with your code
  28.  
  29. def decide_winner(user_choice, computer_move, user_name, user_score, computer_score):
  30. # Figure out who won using if/elif/else
  31. # Rules: paint brush beats canvas, canvas beats palette, palette beats paint brush
  32. if computer_move == user_choice:
  33. print("It's a tie!")
  34. return "tie"
  35.  
  36. elif computer_move == "paintbrush" and user_choice == "palette":
  37. print("You won? The computer shall seek its revenge!")
  38. user_score += 1
  39. return "player"
  40.  
  41. elif computer_move == "palette" and user_choice == "canvas":
  42. print("You won! Well... Beginner's luck. The computer shall triumph!")
  43. user_score += 1
  44. return "player"
  45.  
  46. elif computer_move == "canvas" and user_choice == "paintbrush":
  47. print(f"HOW DARE YOU WIN AGAINST THE ALL POWERFUL COMPUTER! WITCHCRAFT! YOU CANNOT ESCAPE ME {user_name}!!!")
  48. user_score += 1
  49. return "player"
  50.  
  51. elif computer_move == "palette" and user_choice == "paintbrush":
  52. print(f"You lost. Don't worry, {user_name}. There's always next time!")
  53. computer_score += 1
  54. return "computer"
  55.  
  56. elif computer_move == "canvas" and user_choice == "palette":
  57. print(f"Uh oh, you lost :( Don't fret, {user_name}. There's always next time!")
  58. computer_score += 1
  59. return "computer"
  60.  
  61. elif computer_move == "paintbrush" and user_choice == "canvas":
  62. print(f"You lost? Better luck next time, {user_name}.")
  63. computer_score += 1
  64. return "computer"
  65. # If both picked the same thing, return the string 'tie'
  66. # If the player won, return the string 'player'
  67. # If the computer won, return the string 'computer'
  68. # Replace pass with your code
  69.  
  70. def play_one_round():
  71. user_name = get_player_name()
  72. player = get_player_choice()
  73. computer = choose_computer_move()
  74. winner = decide_winner(player, computer, user_name, computer_score, user_score)
  75. print(player)
  76. print(computer)
  77. print(winner)
  78.  
  79. # Run the game
  80. play_one_round()
Advertisement
Add Comment
Please, Sign In to add comment