Modified from Chapter 07 Programming Exercise 5 Original Exercise: Rock, Paper, Scissors Modification Programming Exercise 11 in Chapter...

50.1K

Verified Solution

Question

Programming

Modified from Chapter 07 Programming Exercise 5

Original Exercise:

Rock, Paper, Scissors Modification
Programming Exercise 11 in Chapter 6 asked you to design a programthat plays the Rock, Paper, Scissors game. In the program, the userenters one of the three strings—\"rock\", \"paper\", or \"scissors\"—atthe keyboard. Add input validation (with a case-insensitivecomparison) to make sure the user enters one of those stringsonly.

Modifications:

  • Allow the user to input \"r\", \"p\", \"s\" or the full strings\"Rock\", \"Paper\", \"Scissors\"
    • Allow the user to input upper or lowercase
    • try the following:
      • input = input.lower()
  • Refer to the following code to help generate a random computerplayer action
    • import random
      pc_choice_list = [\"rock\", \"paper\", \"scissors\"]
      pc_choice = random.choice(pc_choice_list)
  • Allow the player to input a \"q\" for their turn if they want toquit the game
  • Use loops not only to validate the input but also to keep thegame running as long as the player does not input a \"q\" on theirturn
  • Example outputs
    • Rock beats Scissors
    • Paper beats Rock
    • Scissors beats Paper
    • Tie
    • Game Over
    • Let's Play Rock, Paper, Scissors
      Input your choice: r,p, or s

Turn IN:

Raptor flowchart file (or alternative flowchartscreenshot)
        If you are on Windowsplease try using the built-in \"Snip & Sketch\" program to take aperfectly sized screenshot.
Thonny Python file (or Python file is written in anyIDE/program)
        Turn in the actualPython code file \"file_name.py\"

Answer & Explanation Solved by verified expert
4.1 Ratings (669 Votes)
import random import random for pcchoicepcchoicelist rock paper scissors choices with computercheck False variable to check whether q has been pressed or notwhile check False loop will run until q is pressed pcchoice randomchoicepcchoicelist randomly pc selecting its choice    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students