3.plese to write the correct code:
The code below will loop as long as the number that you enter isn’t negative. It will add each non negative number to the current sum. It will print out the sum and average of all of the numbers you have entered. But someone jumbled up the code. Can you reorganize and indent it so it works properly?
count = count + 1
message = "Enter an integer or a negative number to stop"
value = input(message)
print("The sum is: " + str(sum) + " the average is: " + str(sum /
count))
print("You entered " + value)
sum = sum + int(value)
count = 0
value = input(message)
while int(value) > 0:
sum = 0
count = 0 sum = 0 message = "Enter an integer or a negative number to stop" value = input(message) while int(value) > 0: print("You entered " + value) sum = sum + int(value) count = count + 1 value = input(message) print("The sum is: " + str(sum) + " the average is: " + str(sum / count))
Get Answers For Free
Most questions answered within 1 hours.