Derious V. answered 03/24/23
Specialized coding tutoring for neurodiverse students!
The steps_to_miles() function takes a parameter steps and checks whether it's negative or not. If it's negative, it raises a ValueError with the specified message. If it's positive or zero, it calculates the equivalent miles walked and returns it.
The main() program reads the number of steps from the user and calls the steps_to_miles() function with it. If the function raises a ValueError, the program catches it using a try-except block and prints the exception message. Otherwise, it prints the miles walked with two digits after the decimal point using formatted string literals.
Hope this helps!