calculating slowest speed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • depasqualen
    New Member
    • Jan 2015
    • 6

    calculating slowest speed

    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!

    Code:
    num_walkers = float(input("How many walkers in your group? "))
    dist = float(input("Enter the distance: "))
    time = float(input("Enter the time: "))
    speed = dist/time
    i = 1
    high_speed = speed
    while i < num_walkers:
        dist = float(input("Enter the distance: "))
        time = float(input("Enter the time: "))
        speed = dist/time
        if speed > high_speed:
            high_speed = speed
        i = i + 1
    print("The fastest speed in the walking group is: ",high_speed)
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    What does line 11 do?

    Comment

    • depasqualen
      New Member
      • Jan 2015
      • 6

      #3
      I changed the > to a < and it finds the slowest,thanks for the tip

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        No problem, good luck with the rest of your project.

        Comment

        Working...