Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with making the rps menu! Please answer in python Here's my code: #import check_input import random def main(): # Variables track the

I need help with making the rps menu! Please answer in python

image text in transcribed

image text in transcribed

Here's my code:

#import check_input import random

def main():

# Variables track the number of wins the Player or the Computer has. Player = 0 Computer = 0 while True: # Main game loop. while True:

list = ["R. Rock", "P. Paper", "S. Scissors", "B. Back"]

for count, num in enumerate(list): print(num) playerMove = input('> ').upper() if playerMove == 'B': print('Thanks for playing!') exit()

if playerMove == 'R' or playerMove == 'P' or playerMove == 'S': break else: print('Type one of R, P, S, or Q.')

# Display what the player chose: if playerMove == 'R': playerMove = "Rock" print("You chose Rock") elif playerMove == 'P': playerMove = "Paper" print("You chose Paper") elif playerMove == 'S': playerMove = "Scissors" print("You chose Scissors")

# Display what the computer chose: random_num = random.randint(1, 3) if random_num == 1: computerMove = "Rock" elif random_num == 2: computerMove = "Paper" elif random_num == 3: computerMove = "Scissors" print(f"Computer chose {computerMove}")

# Display and record the win/loss/tie: if playerMove == computerMove: print("Tie") elif playerMove == "Rock" and computerMove == "Scissors": Player = Player + 1 print("Player wins") elif playerMove == "Paper" and computerMove == "Rock": Player = Player + 1 print("Player wins") elif playerMove == "Scissors" and computerMove == "Paper": Player = Player + 1 print("Player wins") elif playerMove == "Rock" and computerMove == "Paper": Computer = Computer + 1 print("Computer wins") elif playerMove == "Paper" and computerMove == "Scissors": Computer = Computer + 1 print("Computer wins") elif playerMove == "Scissors" and computerMove == "Rock": Computer = Computer + 1 print("Computer wins") main()

It seems that I got the playing portion, but how do i get the menu to pop up?

Rock-Paper-Scissors Write a program that allows a user to play Rock-Paper-Scissors against the computer. Have the program keep score of how many times each has won a round. Your program should have a main method that has a loop that repeats the game until the user chooses to quit. Display the final score before exiting. Write the following functions: 1. weapon_menu ( ) - Asks the user to input their choice: (R)ock, (P)aper, (S)cissors, or (B)ack. Checks user input for validity and then returns the inputted value. 2. comp_weapon ( ) - Randomly chooses the computer's throw and returns an "R", "P", or "S". 3. find_winner (player, comp) - Passes in the two weapons (R, P, or S), displays the throws, compares the two weapons and displays the result and returns who is the winner of that round ( 0= Tie, 1= Player, 2= Computer). a. Rock crushes Scissors b. Scissors cuts Paper c. Paper covers Rock 4. display_scores (player, comp) - Displays the scores. Example Output (user input is in italics): RPS Menu: Computer wins 1. Play game Choose your weapon: 2. Show Score R. Rock 3. Quit P. Paper 1 S. Scissors Choose your weapon: B. Back R. Rock B P. Paper RPS Menu: S. Scissors 1. Play game B. Back 2. Show Score P 3. Quit You chose Paper 2 Computer chose Paper Player =0 Tie Computer =1 Choose your weapon: RPS Menu: R. Rock 1. Play game P. Paper 2. Show Score S. Scissors 3. Quit B. Back 3 S Final Score: You chose Scissors Player =0 Computer chose Rock Computer =1 Notes: 1. You can use the check_input module provided on Canvas to check the user's input in the main menu (not the weapon menu). 2. Use the random module to randomly choose the computer's weapon. 3. Please do not use any lists or global variables. Please pass all necessary values as parameters to your functions. 4. Do not create any extra functions or add any extra parameters. 5. Please read through the Coding Standards document provided on Canvas for guidance on how to name your variables and to format your program. 6. Use docstrings to document each of your five functions. Document all arguments and return values. 7. Place your name, the date, and a brief description of the program in a comment block at the top of your program. 8. Add brief comments in your functions to describe sections of code. 9. Thoroughly test your program before submitting/demoing. a. Make sure each of your functions returns the correct value. b. Make sure the computer's throw returns a randomly assigned weapon choice. c. Make sure that the correct winner is returned given the rules. d. Make sure that the points are awarded to the correct player after winning a round. e. Make sure that the points displayed are correct. f. Make sure that the game doesn't go back to the main menu until the user chooses to go back. g. Error check all user input (1,2,3 on the main menu, and R, P, S, B on the weapon menu). 10. Feel free to expand the game to be the Rock-Paper-Scissors-Lizard-Spock version. Add new menu options for (L) izard and Spoc(k). The updated set of rules are: a. Rock crushes Scissors b. Rock crushes Lizard c. Paper covers Rock d. Paper disproves Spock e. Scissors cuts Paper f. Scissors decapitates Lizard g. Lizard poisons Spock h. Lizard eats Paper i. Spock smashes Scissors j. Spock vaporizes Rock

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions