CIS 1250 Python Program5 – Play a game Turn in Requirements: 5 pts. Name your project LastnameP5, such as GarnerP5. Program Requirements:   5 pts. Add comments as appropriate.  Be sure that your...

CIS 1250 Python Program5 – Play a game Turn in Requirements:

5 pts. Name your project LastnameP5, such as GarnerP5.


Program Requirements:


5 pts. Add comments as appropriate.  Be sure that your program output is neatly presented to the user.


Write a program that does the following:


Initialize an empty list which you will use to store the results of each game.


Start a game of rock paper scissors with to user.


The user will play against the computer.  A scissor can cut paper, a rock can knock a scissor, and paper can wrap a rock.


Open a do-while loop as a play loop.  That way, the player can play the game until the user or the computer has won twice.


Ask the user to select his/her choice (rock, paper, scissors)


After the user has entered his/her choice, the program use a random number generator for its selection.


Your program will evaluate who won or if there was a tie.


The program reports what the computer chose, the user’s choice, who won that round, and game tally. The game tally shows number of rounds, wins/losses for the player and number of ties.


Store that information in your game results list.


Ask the player if the user wants to play again.


When the player is done, write a for loop that displays the game results list.


When done display a goodbye message.


The game should look something like this:



Hints:

You may need to use an if/elif/else block that will look something like:


                If


                elif


                elif


                elif


                else


Remember to indent the blocks of code that come after and are associated with your while, if, elif and else statements.


To generate random numbers use the random library.


Example:


import random


doanother = 'y'


while doanother == 'y':


    someValue = random.randrange(3)


    print someValue


    doanother = raw_input ('Again y/n: ').strip().lower()[0]


Example of using Random:


>>> import random


>>> random.randrange(3)


0


>>> random.randrange(3)


1


>>> random.randrange(3)


2


>>> choices=['rock','paper','scisors']


>>> compchoice = choices[random.randrange(3)]


>>> compchoice


'scisors'


>>>



May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here