Customized step counter Learning Objectives In this lab, you will Create a function to match the specifications Use floating-point value division Instructions A pedometer treats walking 2,000 steps as walking 1 mile. It assumes that one step is a bit over 18 inches (1 mile = 36630 inches, so the pedometers assume that one step should be 18.315 inches). Let's customize this calculation to account for the size of our stride. Write a program whose input is the number of steps and the length of the step in inches, and whose output is the miles walked. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: print(f'{your_value:.2f}') Ex: If the input is: 5345 18.315 the output is: You walked 5345 steps which are about 2.67 miles. Your program must define and call the following function. The function should return the number of miles walked. def steps_to_miles(user_steps, step_length) # Define your function here if __name__ == '__main__': # Type your code here
Customized step counter
Learning Objectives
In this lab, you will
- Create a function to match the specifications
- Use floating-point value division
Instructions
A pedometer treats walking 2,000 steps as walking 1 mile. It assumes that one step is a bit over 18 inches (1 mile = 36630 inches, so the pedometers assume that one step should be 18.315 inches).
Let's customize this calculation to account for the size of our stride. Write a
Output each floating-point value with two digits after the decimal point, which can be achieved as follows: print(f'{your_value:.2f}')
Ex: If the input is:
5345 18.315the output is:
You walked 5345 steps which are about 2.67 miles.Your program must define and call the following function. The function should return the number of miles walked.
def steps_to_miles(user_steps, step_length)
# Define your function here
if __name__ == '__main__':
# Type your code here.
here we are calculating the miles walked based on the number of steps given and the stretch of each step
miles = user_steps * step_length / 36630
and for printing the float value , print(f'{your_value:.2f}') is used where .2 shows that afterdecimal 2 digits are there.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images