1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
soldier1979 [14.2K]
3 years ago
14

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.
So far this is what I have:
if score1>score2:
player1Wins=player1Wins+1
player2Losses=player2Losses+1
print("player1Wins")
elif score2>score1
player2Wins=player2Wins+1
player1Losses=player1Losses+1
print("player2Wins")
else:
score1=score2
tieCount=tieCount+1
print("tie")
___________________________
However, I'm still getting an error and not sure why. Am I indenting something wrong?
Computers and Technology
1 answer:
vaieri [72.5K]3 years ago
8 0

Answer:

player1Wins = player1Losses = player2Wins = player2Losses = tieCount = 0

score1 = 10

score2 = 10

if score1>score2:

   player1Wins=player1Wins+1

   player2Losses=player2Losses+1

   print("player1 wins")

elif score2>score1:

   player2Wins=player2Wins+1

   player1Losses=player1Losses+1

   print("player2 wins")

else:

   tieCount=tieCount+1

   print("tie")

Explanation:

Since your indentation can not be understand what you give us, please try to do it as you see in the answer part.

Although it seems that this is a part of the code, it is normal that you get errors. However, since you keep track of the variables, it is better to initialize the variables that will keep the counts. Since initially, they are 0, you may set them as 0. Also, if you assign the values to the scores, probably you would not get any error. This way, you may test your code as I did.

Other than these, in the else part you do not need to write "score1=score2", because if score1 is not greater than score2 and if score2 is not greater than score1, this already implies that they are equal

You might be interested in
Unlike memory, this type of storage holds data and programs even after electrical power to the computer system has been turned o
Scrat [10]

Answer:

Secondary memory.

Explanation:

Unlike main memory which loses its content when electrical power to the system is turned off, secondary memory is volatile and persistent in nature. i.e it retains its content whether or not power is supplied to the computer that is holding it. As a matter of fact, they (secondary memory) are meant to store data permanently. Examples of such memory are the hard drives, floppy disks, flash drives, CDs and CDROMs.

Also, unlike the primary or main memory that can be accessed directly by the processor of the computer housing it, secondary memory are not accessed directly.

8 0
2 years ago
The Mohs scale is used to express which mineral property?
olchik [2.2K]
Its answer is c. hardness

5 0
3 years ago
Which of these is the best example of an asset?
ArbitrLikvidat [17]

I believe it's the second answer:

The antique diamond necklace someone is wearing

5 0
3 years ago
Classify the following skills: writing HTML code, evaluating color theory, using design principles.
noname [10]

Answer: It’s not soft skills

Explanation: My test did not tell me what the answer is

3 0
3 years ago
Read 2 more answers
What is the best way to describe the relationship between two companies that offer basically the same product or service?
fenix001 [56]
Compare the products together
8 0
2 years ago
Read 2 more answers
Other questions:
  • Which is a real-world example of a procedure?
    11·1 answer
  • When you arrive at work one morning, your inbox is full of messages complaining of a network slowdown. you collect a capture fro
    12·1 answer
  • Which of the following scanning technique attackers use to bypass firewall rules, logging mechanism, and hide themselves as usua
    11·1 answer
  • On your Windows server, you’re planning to install a new database application that uses an enormous amount of disk space. You ne
    11·1 answer
  • Which best describes color blindness?
    8·1 answer
  • Why is the cyber community important???
    8·2 answers
  • For this project you will write a Java program that will run a simple math quiz. Your program will generate two random integers
    15·1 answer
  • HELP!!!
    15·2 answers
  • Taran wants to work in the technology field but is unsure of which career to pursue. He has been told he has strong people skill
    14·1 answer
  • Question 9
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!