By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,116 Members | 1,509 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,116 IT Pros & Developers. It's quick & easy.

calculating slowest speed

P: 6
Hello,
I'm trying to change this script so that it calculates the speed of the slowest walker rather that the fastest walker. I know the change needs to happen in the while or if loop, but I don't know what exactly to change.

I'm still new to python and I'm not really sure where to start, any help would be appreciated. Thanks!

Expand|Select|Wrap|Line Numbers
  1. num_walkers = float(input("How many walkers in your group? "))
  2. dist = float(input("Enter the distance: "))
  3. time = float(input("Enter the time: "))
  4. speed = dist/time
  5. i = 1
  6. high_speed = speed
  7. while i < num_walkers:
  8.     dist = float(input("Enter the distance: "))
  9.     time = float(input("Enter the time: "))
  10.     speed = dist/time
  11.     if speed > high_speed:
  12.         high_speed = speed
  13.     i = i + 1
  14. print("The fastest speed in the walking group is: ",high_speed)
Feb 4 '15 #1

✓ answered by Rabbit

What does line 11 do?

Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,359
What does line 11 do?
Feb 4 '15 #2

P: 6
I changed the > to a < and it finds the slowest,thanks for the tip
Feb 4 '15 #3

Rabbit
Expert Mod 10K+
P: 12,359
No problem, good luck with the rest of your project.
Feb 4 '15 #4

Post your reply

Sign in to post your reply or Sign up for a free account.