Question: A pedometer treats walking 2 , 0 0 0 steps as walking 1 mile. Write a steps _ ( t ) o _ ( m

A pedometer treats walking 2,000 steps as walking 1 mile. Write a steps_(t)o_(m)iles() function that takes the number of steps as a parameter and returns the miles walked. The steps_(t)o_(m)iles() function raises a ValueError object with the message "Exception: Negative step count entered." when the number of steps is negative. Complete the main() program that reads the number of steps from a user, calls the steps_(t)o_(m)iles() function, and outputs the returned value from the steps_(t)o_(m)iles() function. Use a try-except block to catch any ValueError object raised by the steps_(t)o_(m)iles() function and output the exception message.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
print(f'{your_(v)alue:.2f}')
Ex: If the input of the program is:
5345
the output of the program is:
2.67
Ex: If the input of the program is:
-3850
the output of the program is:
Exception: Negative step count entered.
A pedometer treats walking 2,000 steps as walking 1 mile. Write a steps_(t)o_(m)iles() function that takes the number of steps as a
parameter and returns the miles walked. The steps_(t)o_(m)iles() function raises a ValueError object with the message "Exception:
Negative step count entered." when the number of steps is negative. Complete the main1()/()# Define your method here
2,
3 if _(n)name_(_())=='_(_())main_(_())':
4()/()# Type your code here.
A pedometer treats walking 2 , 0 0 0 steps as

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 Programming Questions!