Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Subjects: Write a Python program that allows users to play the popular rock-paper-scissor game against the computer multiple times. This program assesses your knowledge

Subjects: Write a Python program that allows users to play the popular rock-paper-scissor game against the 

Subjects: Write a Python program that allows users to play the popular rock-paper-scissor game against the computer multiple times. This program assesses your knowledge on decision structures, repetition structures, and function. This is a team-based assignment, but you can work by yourself if you prefer. Please include the names of your team members as comments at the top of the python file, and each team only needs to submit one copy on Canvas. Requirements: 1. Define a function named as play_game. This function receives two parameters representing the player's and computer's choices, and it returns an integer representing the game result from the player's perspective. Specifically, it returns 1 if the player wins and 0 if the player does not win. Hint: you can reuse most of the code of team activity 2 as the body of this function. 2. Define the main function. In the main function, write code to let users play the game multiple rounds against the computer. 1) Option 1: use a for-loop to let the player play this game 3 times. For each round of the game, display a message indicating whether the player wins, loses, or draws. After the player has played 3 times, display a message indicating how many times the player has won. 2) Option 2: use a while loop to let the player play this game multiple times and the loop ends when the player wins 3 times. For each round of the game, display a message indicating whether the player wins, loses, or draws. After the player has won 3 times, display a message informing the player that the player has won 3 out of how many of times played. 3) For either option, within each round of the game: a. Let the computer randomly make a choice of scissor, rock, and paper. b. Prompt the player to make the player's choice. c. Call the play_game function to play the game once. 3. Call the main function and test your code. Instructions: You can revise your team activity 2 or start a new file. > > First, you need to design the program. In a Word fille, please define the IPO charts for this problem. For the play-game function, you can modify the design you did for team activity 2. Next, write the python code based on your design. You can choose the names of variables, how to represent the choices for rock, paper, and scissor, and the exact format of the output, etc. However, make sure to include both the computer and the user's choice in each of your print statement so you can verify that you implemented the game rule correctly. Fix any syntax errors and test your code if you can. > > Save your file (especially if you can't run it). Submit both the python file and your program design file through Canvas for grading. Acti Go to

Step by Step Solution

There are 3 Steps involved in it

Step: 1

I am also attching the text version of the code in case you need to copy paste import random ... 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

Recommended Textbook for

Java Concepts Late Objects

Authors: Cay S. Horstmann

3rd Edition

1119186714, 978-1119186717

More Books

Students also viewed these Programming questions