84.2k views
5 votes
How far do you jog each morning? You prefer to jog in different locations each day and do not have a pedometer to measure your distance. Create an application to determine the distance jogged given the average number of strides ran during the fist minute, average number ran during the last minute, and the total minutes jogging. Design a modularized solution (with methods) to display the distance traveled. Pedometers measure the distance you run. However, you can also do a good estimate of the distance if you know your foot stride, how many strides you complete per minute, and the number of minutes you job. Foot stride is the distance covered by one average step length. Since everyone has a different foot size, strides differ. Manny people average 3 feet per setup when jogging. For this application, assume the foot stride is 2.5 feet. There are 5,280 feet in a mile. To establish how many strides per minutes, allow the user to input the number of strides made during the first minute jogging and the number of strides made string the last minutes of jogging. Use the average of those values to represent the strides per minute. Allow the user to input the total time spent jogging in hours and minutes. Write code that will display to distance traveled in miles.

1 Answer

5 votes

Answer:

The program is given below with appropriate comments for better understanding

Step-by-step explanation:

#Program

# foot stride = 2.5 feet

# 1 mile = 5280 feet

no_stride_first_min = int(input('Enter the number strides made durng the first minute of jogging: '))

no_stride_last_min = int(input('Enter the number strides made durng the last minute of jogging: '))

avg_stride_one_min = (no_stride_first_min + no_stride_last_min)/2 # calculates the average stride per minute

jogging_duration = float(input('Enter the total time spent jogging in hours and minute: '))

jogging_duration_hours = int(jogging_duration) # gets the hour

jogging_duration_min = jogging_duration - int(jogging_duration) # gets the minute

tot_jogging_duration_min = jogging_duration_hours*60 + jogging_duration_min # calculates total time in minutes

dist_feet = (avg_stride_one_min*2.5)*tot_jogging_duration_min # calculates the total distance in feet

dist_miles = dist_feet/5280 # calculates the total distance in mile

print('Distance traveled in miles = {0:.2f} miles'.format(dist_miles))

User Shubhanshu Mishra
by
4.1k points