PCEP Data Types, Variables, Basic I/O and Operators • Set 12
PCEP Data Types, Variables, Basic I/O and Operators Practice Test 12 — 15 questions with explanations. Free, no signup.
A junior developer created a Python script to calculate the average of three quiz scores entered by the user. The script reads three numbers using input(), converts them to float, calculates the sum, and divides by 3. However, when a user enters a non-numeric value like 'ten', the script crashes with a ValueError. The developer needs to modify the script to handle such errors gracefully, allowing the user to re-enter the invalid input until a valid number is provided. Which approach should the developer implement to meet this requirement most effectively while following Python best practices?