Answer to Question #239387 in Python for llmmm

Question #239387

Write a statement that compares the values of score1 and score2 and takes the following actions. When score1 exceeds score2, the message “player1 wins” is printed to standard out. When score2 exceeds score1, the message “player2 wins” is printed to standard out. In each case, the variables player1Wins, , player1Losses, player2Wins, and player2Losses, , are incremented when appropriate. Finally, in the event of a tie, the message “tie” is printed and the variable tieCount is incremented.


1
Expert's answer
2021-09-20T00:11:47-0400
play=True
while play:   
    score1=int(input("Score 1: "))
    score2=int(input("Score 2: "))
    player1Wins=0
    player2Wins=0
    player1Losses=0
    player2Losses=0
    tieCount=0


    if (score1 > score2):
        print("player1 wins")
        player1Wins += 1
        player2Losses += 1
    elif (score2 > score1):
        print("player2 wins")
        player1Losses += 1
        player2Wins += 1
    else:
        print("tie")
        tieCount += 1

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS