The following program is intended to ask the user a series of positive numbers a
ID: 3849628 • Letter: T
Question
The following program is intended to ask the user a series of positive numbers and then to compute the sum of all the positive numbers until a negative number is entered. Does it work as intended? Why or why not? Clearly explain. numb = 1.0 while numb > 0: numb = float (input ('Enter a positive number' ' (negative to quit): ')) # check that number is positive so as # not to change value of the total. if numb > 0: total = total + numb print ('Total = ', format (total, '.2f')) No when i run this program. I entered a positive number 200. The output is 200. But I entered a negative number -100. The output didn't display "quit" it displayed -100.Explanation / Answer
No,
Because here we are checking that whether the number is entered is positive or not. But also we need to write the condition that if the number entered is negative what it need to do. Otherwise it won't work like we want.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.