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
How might your use of computers and knowledge of technology systems affect your personal and professional success?
Xelga [282]
Amost all professions include theuse of computers. Knowing a lot about them and the way they work could help you use them when needed in a work environment. It would also make an employer more likely to hire you.
6 0
3 years ago
Read 2 more answers
What does a computer use long-term memory, or ROM, for?
AysviL [449]
The answer is B

Explanation: In contrast, a computer's hard disk or SDD is its long-term memory, where things are stored more or less permanently. ... Nearly all computers also have some way to store information for longer-term access, too.

5 0
2 years ago
#Write a function called is_composite. is_composite should #take as input one integer. It should return True if the #integer is
malfutka [58]

Answer:

// A optimized school method based C++ program to check  

// if a number is composite.  

#include <bits/stdc++.h>  

using namespace std;  

bool isComposite(int n)  

{  

// Corner cases  

if (n <= 1) return false;  

if (n <= 3) return false;  

// This is checked so that we can skip  

// middle five numbers in below loop  

if (n%2 == 0 || n%3 == 0) return true;  

for (int i=5; i*i<=n; i=i+6)  

 if (n%i == 0 || n%(i+2) == 0)  

 return true;  

return false;  

}  

// Driver Program to test above function  

int main()  

{  

isComposite(11)? cout << " true\n": cout << " false\n";  

isComposite(15)? cout << " true\n": cout << " false\n";  

return 0;  

}

Explanation:

3 0
2 years ago
A _____ character is a space, a tab, or a new line.
babunello [35]
Whitespace

--------------------------------------------
5 0
3 years ago
[100 points] Fill in the missing word.
Makovka662 [10]

answer:The cat lady has 3 left cause of the amount

Explanation:

6 0
1 year ago
Other questions:
  • Given positive integer numInsects, write a while loop that prints that number doubled without reaching 100. Follow each number w
    8·1 answer
  • It chapter 2 pennywise
    13·1 answer
  • In Load/Store Architecture, memory is only referenced by load and store instructions.
    15·1 answer
  • Given the variable ip, already declared as a pointer to an integer, write the code to dynamically allocate memory for a single i
    15·1 answer
  • Where is permanent data in the computer stored whenever gym starts his laptop He sees some commands in numbers appearing on the
    12·1 answer
  • What is the Intranet?<br>​
    5·1 answer
  • Write a program that uses a dictionary to store students birthdays. Your program should ask the user what their name is, and loo
    11·1 answer
  • Need answer ASAP!!!!
    14·1 answer
  • What is the definition of a nested function?
    8·1 answer
  • True or false a mirrorless camera has a pentaprism
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!