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
What is a spacecraft virus?
photoshop1234 [79]
A spacecraft virus<span> is a type of bacteria virus that feeds on other bacteria. It got it name because it is mostly shaped like a spacecraft.</span>
4 0
2 years ago
Read 2 more answers
What is the keyboard shortcut for opening the edit hyperlink dialog box
Mademuasel [1]

That would be CTRL+K


https://quizlet.com/122913134/keyboard-shortcuts-flash-cards/


hope this helps!

7 0
3 years ago
Which of the following is not the name of a java wrapper class from the Java API?
11111nata11111 [884]

Answer:

Int

byte

Explanation:

In java there are eight primitive data types has a class dedicated, and then we can find eight wrapper classes, I'm going to let you the next table with the 8 example:

Assume the next table byte and Int are primitive data, the different with byte is only the capital letter Byte.

Primitive Wrapper Class

boolean         Boolean  

byte                 Byte  

char                 Character

int                 Integer  

float                 Float  

double         Double

long                 Long  

short         Short

3 0
3 years ago
What is the default file name in Word??? Plzzzz help me!!!!!
kondaur [170]
If your document does not have any text in it and you haven't set the “Title” property, Word inserts “DocX.docx” as the file name, where the “X” is a number that depends on how many new documents you have created during your current Word session.
7 0
3 years ago
Read 2 more answers
What bug was supposed to start affecting computers on january 1 2000
horsena [70]

Answer: Y2K bug, also called Year 2000 bug or Millennium Bug

5 0
3 years ago
Other questions:
  • For some people , alcohol can cause an uncontrollable blank of the eyes , making good vision almost impossible
    5·1 answer
  • What view and zoom setting do you need for true WYSIWYG display? Why?
    14·1 answer
  • Help me out for this one
    12·1 answer
  • Sarah is creating and formatting a newsletter for her school. Which page layout rules should she consider when doing this?
    13·2 answers
  • 8.5 question 2 edhesive
    11·1 answer
  • An inventory clerk, using a computer terminal, views the following on screen: part number, part description, quantity on hand, q
    8·1 answer
  • Create a datafile called superheroes.dat using any text-based editor, and enter at least three records storing superheroes’ name
    9·1 answer
  • What does t'challa actions reveal about his character( black panther movie)​
    6·1 answer
  • Which relation is created with the primary key associated with the relationship or associative entity, plus any non-key attribut
    6·1 answer
  • Choose the term that matches each description.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!