Question

Python please. I have a working one that doesn't keep track of w/l ratio, it may...

Python please. I have a working one that doesn't keep track of w/l ratio, it may be helpful to see how others did the entire program and inserted that module.

Write a modular program that let the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows:

  1. When the program begins, a random number in the range of 1 thru 3 is generated but do not display the computer choice immediately.
    • Number 1 is a rock
    • Number 2 is paper
    • Number 3 is scissors
  2. The user enters his or her choice of 1, 2 or 3 corresponding to the same choices as the computer.
  3. Display the computer choice.
  4. A winner is selected based on the following:
    • Choices of rock & scissors, rock wins (rock breaks scissors)
    • Choices of scissors & paper, scissors wins (scissors cuts paper)
    • Choices of paper & rock, paper wins (paper covers rock)
    • Choices are the same, game is replayed to determine a winner.

Keep track of wins and loses for each player, and keep the program running until the player chooses to end the game.

Minimum modules are: computer choice, user choice, win/lose, print

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import random

totalRounds = 0

humanWins = 0

humanLosses = 0

humanTies = 0

computerWins = 0

computerLosses = 0

computerTies = 0

uc = 0

cc = 0

rndNbr = 0

print('Welcome to the Rock-Paper-Scissors Game!!')

print('Have fun and good luck.\n')

totalRounds = int(input('Please enter the number of rounds you must need to win the match:'))

while humanWins != totalRounds and computerWins != totalRounds:

    rndNbr += 1

    uc = int(input('\nPlease enter your choice (1 = ROCK, 2 = PAPER, 3 = SCISSORS): '))

    if uc == 1:

        print('You chose ROCK.')

    elif uc == 2:

        print('You chose PAPER.')

    elif uc == 3:

        print('You chose SCISSORS.')

    else:

        print('You chose an invalid item.')

    cc = random.randint(1, 3)

   if cc == 1:

        print('The computer chose ROCK.')

    elif cc == 2:

        print('The computer chose PAPER.')

    elif cc == 3:

        print('The computer chose SCISSORS.')

    else:

        print('The computer chose an invalid item.')

    if uc == cc:

        winner = 'Tie'

    elif uc == 1 and cc == 2:

        winner = 'Computer'

    elif uc == 1 and cc == 3:

        winner = 'Human'

    elif uc == 2 and cc == 1:

        winner = 'Human'

    elif uc == 2 and cc == 3:

        winner = 'Computer'

    elif uc == 3 and cc == 1:

        winner = 'Computer'

    elif uc == 3 and cc == 2:

        winner = 'Human'

    else:

        print('Winner cannot be determined')

        winner = 'cannot be determined'



    print('\nThe winner of round ', rndNbr, ' is: ', winner)

    if winner == 'Human':

        humanWins += 1

        computerLosses += 1

    elif winner == 'Computer':

        computerWins += 1

        humanLosses += 1

    elif winner == 'Tie':

        humanTies += 1

        computerTies += 1

  else:

        print('Winner cannot be determined')

    print('                               Wins Losses   Ties          ')

    print('Current Human Player Score   : ', humanWins, ' - ', humanLosses, ' - ', humanTies)

    print('Current Computer Player Score: ', computerWins, ' - ', computerLosses, ' - ', computerTies)

if humanWins == totalRounds:

    print('\nThe winner of the match is the human player.')

elif computerWins == totalRounds:

    print('\nThe winner of the match is the computer player.')

else:

    print('\nWinner cannot be determined')

print('                            Wins Losses   Ties          ')

print('Final Human Player Score   : ', humanWins, ' - ', humanLosses, ' - ', humanTies)

print('Final Computer Player Score: ', computerWins, ' - ', computerLosses, ' - ', computerTies)

---------------------------------------------------------------------------------------------------
SEE OUTPUT/CODE FOR INDENTATION

code for indentation

PLEASE COMMENT if there is any concern.

==============================

Add a comment
Know the answer?
Add Answer to:
Python please. I have a working one that doesn't keep track of w/l ratio, it may...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hello, I have this programing assignment that I have to do and I am having issues...

    Hello, I have this programing assignment that I have to do and I am having issues on how to solve it. The program has to be on Java. -thank you in advance. 1- The game Paper, Rock, Scissors is played between two people. Each person counts "one, two, three" and on three displays their hands as either flat - Paper, a fist - Rock or two spread fingers - Scissors. The winner is determined by these rules: Paper covers Rock...

  • C++ Part 2: Rock Paper Scissors Game Write a program that lets the user play this...

    C++ Part 2: Rock Paper Scissors Game Write a program that lets the user play this game against the computer. The program should work as follows: When the program begins, a random number between 1 and 3 is generated. If the number is 1, the computer has chosen rock. If the number is 2, the computer has chosen paper. If the number is 3, the computer has chosen scissors. Don't display the computer's choice yet. Use a menu to display...

  • IN JAVA. Write a program that lets the user play the game of Rock, Paper, Scissors...

    IN JAVA. Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet....

  • (Java) Write a program that lets the user play the game of Rock, Paper, Scissors against...

    (Java) Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet. The...

  • Write a Python program (using python 3.7.2) that lets the user play the game of Rock,...

    Write a Python program (using python 3.7.2) that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don’t display the...

  • please help me fix this. I'm getting it all mixed up in user defined functions. here's...

    please help me fix this. I'm getting it all mixed up in user defined functions. here's the question. This week we'll write a C program that lets the user play the game of Rock, Paper, Scissors against the computer. Your program will call a user-defined function named display_rules that displays the rules of the game. It then proceeds to play the game. To determine the winner, your program will call another user- defined function called determine_winner that takes two integer...

  • In python: The randrange(min, max) produces a random integer greater than or equal to min and...

    In python: The randrange(min, max) produces a random integer greater than or equal to min and less than max. So randrange(0,3) produces either 0, 1, or 2 Write a program that asks the user to input paper, rock, scissors, or done If they input something else, repeat  the question. If they input 'done', exit the game loop. If they input rock, paper, or scissors, have the computer pick a random choice. Write a function that takes two strings, each 'rock', 'paper',...

  • In python language Write a program that lets the user play the game of Rock, Paper,...

    In python language Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows: 1. When the program begins, a random number in the range of 1 and 3 is generated. 1 = Computer has chosen Rock 2 = Computer has chosen Paper 3 = Computer has chosen Scissors (Dont display the computer's choice yet) 2. The user enters his or her choice of “Rock”, “Paper", “Scissors" at...

  • Use Dev C++ for program and include all of the following. Im lost. Make sure the...

    Use Dev C++ for program and include all of the following. Im lost. Make sure the user enters a letter of R, P, or S and the computer generates a number between 0-2 and changes that number to a letter of R, P or S, using a switch. Make sure the user knows why he/she has won or lost – print a message like “Paper covers Rock” or “Scissors cuts Paper”. Ask the user how many times he/she wants to...

  • java pls Rock Paper Scissors Lizard Spock Rock Paper Scissors Lizard Spock is a variation of...

    java pls Rock Paper Scissors Lizard Spock Rock Paper Scissors Lizard Spock is a variation of the common game Rock Paper Scissors that is often used to pass time (or sometimes to make decisions.) The rules of the game are outlined below: • • Scissors cuts Paper Paper covers Rock Rock crushes Lizard Lizard poisons Spock Spock smashes Scissors Scissors decapitates Lizard Lizard eats Paper Paper disproves Spock Spock vaporizes Rock Rock crushes Scissors Write a program that simulates the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT