Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a PYTHON program. Use COMMENTS and DOCSTRINGS for explanations. This is a sample output and the suggestions Homework 5-The Wheels on the Bus Go

Write a PYTHON program. Use COMMENTS and DOCSTRINGS for explanations.
image text in transcribed
This is a sample output and the suggestions
image text in transcribed
Homework 5-The Wheels on the Bus Go Round and Round! Due: Tuesday, February 19 Purpose: A real-world simulation using a Python list and random numbers. Deliverables: A Python program in your Homework 5 K: drive folder. Remember to use comments and docstrings in your programs. Put your name in a comment near the beginning of the Python program file. Name your program file 'busRoute.py In this program you will simulate a public transit bus traveling on a bus route. You can think of a Pace bus or a CTA bus for this assignment. The bus has seats for 30 passengers. The bus has 10 stops that are named for the cross streets where it stops. The streets are named "Ardmore", "Belmont", "Chicago", "Devon", "Erie", "Fullerton", "Greenleaf", "Howard", "Illinois", and "Jackson". - At each stop people get on and off the bus. - A random number of people (as many as 10 people) will get on the bus at each stop. o A random number of people (as many as are on the bus) will get off of the bus. o - For each stop, print out the name of the stop, the number of people who got on the bus the number of people who got off of the bus, the number of people who are now on the bus, and the percent of the seats that are still unoccupied and available for passengers Program Design Requirements: You will write a main function and two other functions. The main function will display all of the information that you see in the sample program output on the next page. The main function will use a list to store the names of the bus stops. The main function will call the other two functions. One of the other two functions will calculate the number of people who get on the bus at each stop. The number of people who get on the bus is a whole number between 0 and 10, inclusive. The other function will calculate the number of people who get off the bus at each stop. The number of people who get off the bus is a whole number between 0 and the number of people who are on the bus, inclusive. Each of these random number functions will return the number that they generate. Your program will format the output as a table as seen in the sample output. It will use column headings and format strings to align columns and the data within each column. The program does not need any input from the user in order to run. Here is a sample run of the program. Because the number of people getting on and off are random numbers, your results will look different: Public Transit Bus Simulation % Available Stop # Board # Depart # Remain Seats Ardmore Belmont Chicago 6 Devon Erie Fullerton 1 Greenleaf 6 Howard Illinois 7 Jackson 2 83.33% 96.67% 80 . 00% 86.67% 76.67% 90.00% 63. 33% 66.67% 70.00% 18 Program Design Suggestions: 1) First write the heading ("def") lines for each of the three functions. Leave a few blank lines between each def line for the bodies of the functions. Call the main function at the bottom of the Python program. 2) Print the report heading and column headings in the main function. Note that the heading for the last column uses two lines on the screen. It is easiest to use a separate print) statement for each of these lines. 3) Use a for loop and the list of bus stop names to produce the lines of output in the body of the table. We've used a list to control a for loop multiple times in this class, starting in Week 1. There are several examples on the K: drive that you can look at for ideas. You will call the other two functions from within the for loop. The print statement that is in the for loop will use format specifiers. The bus stop names are aligned along the left edge. The numbers of people boarding, departing, and remaining on the bus are aligned according to the place values of the columns. The percent of seats remaining is a decimal number with two places after the decimal. 4)

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

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions