Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

can you help me fix this code in the language python? The code need to print out

ID: 3792732 • Letter: C

Question

can you help me fix this code in the language python? The code need to print out a message" you didn't enter any number" when the input is only 0.

total = 0
posCount = 0
negCount = 0
count = 0
n = int(input("Enter the value(0 to quit): "))

while n != 0:
total = total + n
count = count + 1
if n < 0:
negCount = negCount + 1
n = int(input("Enter the value(0 to quit): "))
else:
posCount = posCount + 1
n = int(input("Enter the value(0 to quit): "))
average = total/float(count)
print ("Postive numbers count: ", posCount)
print ("Negative numbers count: ", negCount)
print ("Total: ", total)
print ("Average: ", average)

Explanation / Answer

Now your code is working please check it out.

total = 0
posCount = 0
negCount = 0
count = 0
n = int(input("Enter the value(0 to quit): "))
if n == 0:

print ("You entered 0, quiting...")
quit()
while n != 0:
    total = total + n
    count = count + 1
    if n < 0:
        negCount = negCount + 1
        n = int(input("Enter the value(0 to quit): "))
    else:
        posCount = posCount + 1
        n = int(input("Enter the value(0 to quit): "))
      
average = total/float(count)
print ("Postive numbers count: ", posCount)
print ("Negative numbers count: ", negCount)
print ("Total: ", total)
print ("Average: ", average)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote