"write a program to play and score the paper-rock-scissor game. each of two users types in either p, r, or s. the program then announces the winner as well the basis for determining the winner: paper covers rock, rock breaks scissors, scissors cut paper, or nobody wins. be sure to allow the users to use lowercase as well uppercase letters. your program should include a loop that lets the user play again until the user says she or he is done."

Respuesta :

The program is an illustration of conditional statements.

Conditional statements are used to execute instructions, if and only if certain condition or conditions are met.

Take for instance: If b = 5, print "ab"

The above print statement will only be executed, if the value of b is 5

The paper-rock-scissor program in Python where comments are used to explain each line is as follows,  

#This imports the random module

import random

#This is used to control the repetition of the game

playagain ="T"

#The following is repeated until the user chooses not to play again

while(playagain == "T"):

   #This generates a random choice for the computer

   computer = random.choice(['Rock', 'Paper', 'Scissors'])

   #This gets input for the player

   player = input('Choose: ')

   #If the player and computer choose the selection

   if player == computer:

       #Then, it's a tie

       print('A tie - Both players chose '+player)

   #If the player wins

   elif (player.lower() == "Rock".lower() and computer.lower() == "Scissors".lower()) or (player.lower() == "Paper".lower() and computer.lower() == "Rock".lower()) or (player == "Scissors" and computer.lower() == "Paper".lower()):

       #This prints "player won" and the reason

       print('Player won! '+player +' beats '+computer)

   #If otherwise,

   else:

       #This prints "computer won" and the reason

       print('Computer won! '+computer+' beats '+player)

   #This asks if the player wants to play again

   playagain = input("Play again? T/F: ")

At the end of each round,

  • The program displays the winner
  • Or prints a tie, if there's a tie

See attachment for sample run

Read more about conditional statements at:

https://brainly.com/question/22078945

Ver imagen MrRoyal