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
I need help plz it’s python
algol13

Answer:

The output of the first question would be 9. And the answer the second question is 10.

8 0
2 years ago
Write a class called SimpleSquare that has the following properties: - public int field called num - private int field called sq
mezya [45]

Answer:

public class SimpleSquare{

   public int num;

   private int square;

   

   public SimpleSquare(int number){

       num = number;

       square = number * number;

   }

   

   public int getSquare(){

       return square;

   }    

}

Explanation:

*The code is in Java.

Create a class called SimpleSquare

Declare two fields, num and square

Create a constructor that takes an integer number as a parameter, sets the num and sets the square as number * number.

Since the square is a private field, I also added the getSquare() method which returns the value of the square.

6 0
2 years ago
What are the binary symbols?
alexgriva [62]

Answer:

Explanation:

a binary number is a number expressed in the base-2 numeral system or binary numeral system

4 0
3 years ago
Read 2 more answers
Which of the following items is not considered a personal risk factor for ergonomic hazards? A. Body size B. Medical condition C
serious [3.7K]
I think it might be a. body size .
6 0
3 years ago
Read 2 more answers
There are 2048bytes in4megabytes true or false​
ollegr [7]

Answer:

Explanation:

bonjour,

1 MB =  1 000 000 B (bytes)

4 MB = 4 000 000B

=> false

5 0
2 years ago
Other questions:
  • What are the planes used to allow SDN to virtualize parts of the physical network so that it can be more quickly and easily reco
    6·1 answer
  • 20 Points!! Please hurry!!
    9·1 answer
  • A database interrogation is a major benefit of the database management approach, where end users can query (“ask”) the database
    6·1 answer
  • How should you decide what to wear to an interview? What kind of things should be considered?
    12·1 answer
  • A group of students are collaborating on an online research project. What is an example of appropriate online behavior?
    10·2 answers
  • A sense of scale tells us what about the objects in a picture?
    11·2 answers
  • Technology trends in education play a key role in a student’s
    15·1 answer
  • The overall cost of wiring in addressable fire alarm system is significantly cheaper than the conventional one. Why is it so?
    14·1 answer
  • Select the correct answer from each drop-down menu.
    7·1 answer
  • A brick has a weight of 23N. The brick is flat and smooth on the side in contact with the floor having measurements ( height= 5c
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!