Question: Question 1 2 ( 1 point ) Suppose you want to use a string sentinel value of Q to quite a loop instead

Question 12(1 point)
Suppose you want to use a string sentinel value of "Q" to quite a loop instead of a number. What needs to change in the following code snippet for this to work?
total =0.0
count =0
userInput = float (input("Enter a value or Q to quit: "))
while userInput !="Q" :
total = total + userInput
count = count +1
userInput = float (input("Enter a value or Q to quit: "))
Nothing. The code works correctly
Q should be in single qtotes, 'Q'
count should be updated outside the loop
The conversion of userInput to a floating-point value should be done inside the while loop after reading in a value.
 Question 12(1 point) Suppose you want to use a string sentinel

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!