Rachel M.

asked • 03/09/23

I need help getting the correct output for my function. *Check comments for more info*

def run_sim(stops, boarding_rate, exiting_rate, passengers):

  stop_count = 1

  while stop_count <= stops:

    if stop_count == stops:

      boarding = 0

      departing = passengers

    else:

      boarding = boarding_rate

      departing = min(passengers, exiting_rate)

    print(f"{stop_count:^10d}{passengers:^10d}{boarding:^10d}{departing:^10d}")

    stop_count += 1

    if stop_count <= stops:

      passengers = calc_boarded(boarding, departing, passengers)

  print(f"Final Stop: {passengers} on the bus")*line that needs removed*

print(run_sim(10, 15, 10, 5))

Rachel M.

The output for my function is a table. I need the function to only print out the table. But as it is currently it will print out the function plus the final number of passengers. If I get rid of that line it will return none after the output. If I use return "", it adds an empty line after the output.
Report

03/09/23

Rachel M.

correct output <1 5 15 5 > <2 15 15 10> <3 20 15 10> <4 25 15 10> <5 30 15 10> <6 35 15 10> <7 40 15 10> <8 45 15 10> <9 50 15 10> <10 55 0 55>
Report

03/09/23

2 Answers By Expert Tutors

By:

Bradley T. answered • 03/10/23

Tutor
5 (4)

Tutor for Python and High School and Middle School Math

Rachel M.

Thank you so much! The first method is what I used so it would pass the required test methods. Have a good rest of your day/night!
Report

03/10/23

Khadeer P. answered • 03/15/23

Tutor
New to Wyzant

7996468281Data engineer and Trainer with expertise in Python

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.