
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Please make sure to follow what is given!!!
![• Do not add statements that call print, input , or open , or add an import statement.
• Do not use any break or continue statements. We are imposing this restriction (and we have not even taught you
these statements) because they are very easy to abuse, resulting in terrible, hard to read code.
• Do not modify or add to the import statements provided in the starter code.
import math
from typing import List, TextIO
# For simplicity, we'll use "Station" in our type contracts to indicate that
# we mean a list containing station data.
# You can read "Station" in a type contract as:
List[int, str, float, float, int, int, int]
23
# where the values at each index represent the station data as described in the
# handout on Quercus.
# A set of constants, each representing a list index for station information.
ID - 0
NAME - 1
LATITUDE - 2
LONGITUDE - 3
CAPACITY - 4
BIKES_AVAILABLE - 5
DOCKS_AVAILABLE - 6
NO_KIOSK - 'SMART"
# For use in the get_lat_lon_distance helper function
EARTH RADIUS - 6371
# SAMPLE DATA TO USE IN DOCSTRING EXAMPLES
SAMPLE_STATIONS - [
[7090, 'Danforth Ave / Lamb Ave',
43.681991, -79.329455, 15, 4, 10],
[7486, "Gerrard St E / Ted Reeve Dr',
43.684261, -79.299332, 24, 5, 19],
[7571, 'Highfield Rd / Gerard St E - SMART",
43.671685, -79.325176, 19, 14, 5]]
HANDOUT_STATIONS - [
[7000, 'Ft. York / Capreol Crt.',
43.639832, -79.395954, 31, 20, 11],
[7001, 'Lower Jarvis St SMART / The Esplanade',
43.647992, -79.370907, 15, 5, 10]]](https://content.bartleby.com/qna-images/question/5da1a8b3-4dda-44c5-977e-a3d5025a2246/e6af1b2d-4b37-4f61-b3b5-fef0c160cee7/nq5nwc_thumbnail.png)
Transcribed Image Text:• Do not add statements that call print, input , or open , or add an import statement.
• Do not use any break or continue statements. We are imposing this restriction (and we have not even taught you
these statements) because they are very easy to abuse, resulting in terrible, hard to read code.
• Do not modify or add to the import statements provided in the starter code.
import math
from typing import List, TextIO
# For simplicity, we'll use "Station" in our type contracts to indicate that
# we mean a list containing station data.
# You can read "Station" in a type contract as:
List[int, str, float, float, int, int, int]
23
# where the values at each index represent the station data as described in the
# handout on Quercus.
# A set of constants, each representing a list index for station information.
ID - 0
NAME - 1
LATITUDE - 2
LONGITUDE - 3
CAPACITY - 4
BIKES_AVAILABLE - 5
DOCKS_AVAILABLE - 6
NO_KIOSK - 'SMART"
# For use in the get_lat_lon_distance helper function
EARTH RADIUS - 6371
# SAMPLE DATA TO USE IN DOCSTRING EXAMPLES
SAMPLE_STATIONS - [
[7090, 'Danforth Ave / Lamb Ave',
43.681991, -79.329455, 15, 4, 10],
[7486, "Gerrard St E / Ted Reeve Dr',
43.684261, -79.299332, 24, 5, 19],
[7571, 'Highfield Rd / Gerard St E - SMART",
43.671685, -79.325176, 19, 14, 5]]
HANDOUT_STATIONS - [
[7000, 'Ft. York / Capreol Crt.',
43.639832, -79.395954, 31, 20, 11],
[7001, 'Lower Jarvis St SMART / The Esplanade',
43.647992, -79.370907, 15, 5, 10]]
![def upgrade stations (threshold: int, num bikes: int,
stations: List["Station"]) -> int:
"" "Modify each station in stations that has a capacity that is less than
threshold by adding num bikes to the capacity and bikes available counts.
Modify each station at most once.
Return the total number of bikes that were added to the bike share network.
Precondition: num bikes >= 0
>>> handout_copy = [HANDOUT_STATIONS[0] [:1, HANDOUT_STATIONS [1] [:]]
>>> upgrade_stations (25, 5, handout_copy)
5
>>> handout_copy[0]
== HANDOUT STATIONS [0]
True
== [7001, 'Lower Jarvis St SMART / The Esplanade', \
43.647992, -79.370907, 20, 10, 10]
>>> handout_copy[1]
True](https://content.bartleby.com/qna-images/question/5da1a8b3-4dda-44c5-977e-a3d5025a2246/e6af1b2d-4b37-4f61-b3b5-fef0c160cee7/aift9gf_thumbnail.png)
Transcribed Image Text:def upgrade stations (threshold: int, num bikes: int,
stations: List["Station"]) -> int:
"" "Modify each station in stations that has a capacity that is less than
threshold by adding num bikes to the capacity and bikes available counts.
Modify each station at most once.
Return the total number of bikes that were added to the bike share network.
Precondition: num bikes >= 0
>>> handout_copy = [HANDOUT_STATIONS[0] [:1, HANDOUT_STATIONS [1] [:]]
>>> upgrade_stations (25, 5, handout_copy)
5
>>> handout_copy[0]
== HANDOUT STATIONS [0]
True
== [7001, 'Lower Jarvis St SMART / The Esplanade', \
43.647992, -79.370907, 20, 10, 10]
>>> handout_copy[1]
True
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps with 2 images

Knowledge Booster
Similar questions
- 94% @ @ 1:07 م امتحان الحاسبات النهائي الكورس الثا... الوقت المتبقي 02:52:53 غير مجاب عليه بعد الدرجة من 2.00 التالي > Which of the following statements regarding MATLAB ?workspace is true .a. Items from workspace are deleted using clear .b. Contains just variables c. Items from workspace are cleared using the .clc command .d. Contains folders and files أخل اختياري > سؤال 20 اخترأحد الخيارات د السابقarrow_forwardCreate an algorithm to calculate the price of a pizza per square inch given the radius of the pizza in inches and the price of the pizza.arrow_forwardNormal communications no longer use "save and forward" Check the mechanics.arrow_forward
- Python: Write a python script to find the lesser of two numbers. Take a screenshot of the command with the output.arrow_forwardUsing Python Matplot display a bar chart showing the response frequencies and their percentages of the total responses. This is the list below to use Twenty students were asked to rate on a scale of 1 to 5 the quality of the food in the student cafeteria, with 1 being “awful” and 5 being “excellent.” 1, 2, 5, 4, 3, 5, 2, 1, 3, 3, 1, 4, 3, 3, 3, 2, 3, 3, 2, 5 Bar chart should look like the image belowarrow_forwardExplainarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY