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

Using Python - Implement function inValues() that asks the user to input a set o

ID: 3762935 • Letter: U

Question

Using Python - Implement function inValues() that asks the user to input a set of nonzero floating- point values. When the user enters a value that is not a number, give the user a second chance to enter the value. After two mistakes in a row, quit the program. Add all correctly specified values when the user enters 0. Use exception handling to detect improper inputs.

specified values when the user enters 0. Use exception handling to detect improper inputs.

>>> inValues()

Please enter a number: 4.75

Please enter a number: 2,25

Error. Please re-enter the value.

Please enter a number: 2.25

Please enter a number: 0

7.0

>>> inValues()

Please enter a number: 3.4

Please enter a number: 3,4

Error. Please re-enter the value.

Please enter a number: 3,4

Two errors in a row. Quitting ...

Explanation / Answer

def inValues():
counter = 0
a=0

while True:
if counter <= 2:
try:
value=input(‘enter a value’)
counter=1
float value = float(value)
break
else:
break
except:
if value!=nonzero
print(‘reenter a value’)
errorcounter+=1
printf(‘two mistakes quit the program’)
except:
a += float(value)

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