Hello. I am having a bit of trouble with this code. Its about making a running log using O(n) (linear) notation but I keep having problems figuring it out. I would appreciate the help for figuring out this code. Thanks. This is the problem: Write a program that: Asks the user for number of runs For each run, ask the user What the distance was in miles (in decimal format, e.g. 3.1 miles is acceptable) What the time was in minutes (in decimal format, e.g. 23.9 minutes is acceptable) Output the average pace (in minutes per mile) of all runs. Please paste the code down below. Thanks.
Hello. I am having a bit of trouble with this code. Its about making a running log using O(n) (linear) notation but I keep having problems figuring it out. I would appreciate the help for figuring out this code. Thanks.
This is the problem:
Write a program that:
- Asks the user for number of runs
- For each run, ask the user
- What the distance was in miles (in decimal format, e.g. 3.1 miles is acceptable)
- What the time was in minutes (in decimal format, e.g. 23.9 minutes is acceptable)
- Output the average pace (in minutes per mile) of all runs.
Please paste the code down below. Thanks.
Step-1: Start
Step-2: Declare variable num_runs and take input from the user
Step-3: Declare variable total_distance, total_time and assign value 0
Step-4: Start loop for i in range(num_runs)
Step-4.1: Declare variable distance and take input from the user
Step-4.2: Declare variable time and take input from the user
Step-4.3: In total_distance assign total_distance + distance
Step-4.4: In total_time assign total_time + time
Step-5: Declare variable average_pace and assign total_time / total_distance
Step-6: Print average_pace
Step-7: Stop
Step by step
Solved in 4 steps with 2 images