Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Please answer the following question using Python 3. Please also show the outputs and share your code. Please answer all the questoins and don't

1. Please answer the following question using Python 3. Please also show the outputs and share your code. Please answer all the questoins and don't do by hand.

Bus arrival times.

Shuttle buses arrive at an airport to fetch passengers with an average interval of 15 minutes. Their actual interarrival times follow an exponential distribution.

Write a function simulate_busses(mean, num_busses) that simulates bus arrival times

Use a random module to generate the exponentially distributed bus intervals.

Round your raw data to the nearest tenth of a minute. Realize that rounding is generally scary, and can cause serious problems downstream if not done only when appropriate.

Call your function to generate a list of 50 arrival times with mean 15; capture the result in a variable called bus_times. Print your list, and be sure to commit the output.

For example, your list might begin [11.2, 34.1, 18.8, 23.5, ....

Use Python to answer the following questions:

What is the shortest waiting time in your list?

What is the longest waiting time?

These answers must be programmatically determined and the output that proves you computed them (namely, the values) must be committed.

When answering the previous question, did you write a function? Why or why not?

Cumulative waiting times.

In this problem, you'll interpret the data you generated in Problem 2(a) as a sequence of consecutive arrival times. Suppose the first bus arrives at the measured number of minutes after midnight. The bus company wants to track the time each bus arrived, measured in minutes after midnight.

Write a function that transforms the bus arrival times into cumulative times. The function takes in a list of arrival times, and returns a list of the number of minutes after midnight that each bus arrived at, using the list you generated in part (a).

This assumes the first bus arrived at the airport terminal at midnight plus its arrival time (the time at bus_times[0]). The second arrived at the arrival time of the first plus its arrival time, etc.

I'm deliberately not naming your function for you, here. You get to choose! Make it descriptive!

With the data from our example in part (a), the answer would start [11.2, 45.3, 64.1, 87.6, ...], where 45.3 = 11.2+34.1. Call your function on your variable that you already have in memory. Print your cumulative waiting time list.

Using the list generated in 2(a), at what time does the 50th bus arrive? Print the time in the format HH:MM AM/PM where HH is the hour and MM is the minute.

On the printing of the times

Note that HH should be between 01 and 12.

You must print that leading 0 in the hour and minute, if it is less than 10.

Do not generate a new list of times; be sure to re-use the list of intervals you already generated in 2(a).

I strongly suggest you write a function to stringify the floating point number.

It eats the floating point number, interpreted as number of minutes past midnight.

It returns a string, composed of the hours, minutes, and morning/afternoon indicator.

To solve this problem, take a random number of minutes, and do the computation yourself, and write down the steps you take to do it. That's what you should make the computer do!

Test the function as you develop it, with some known inputs and the times they should map to; e.g., 125.0 is "02:05 AM", and so is 125+24*60.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions

Question

What is a business model?

Answered: 1 week ago