# 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] # # 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 / Gerrard 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]]
# 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] # # 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 / Gerrard 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]]
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Do not add import statements
![# 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]
#
#
# 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
САРАСІTY - 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 / Gerrard 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]]](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2597cbfd-8e09-416c-9d3e-8f104965bd19%2F9e927fc5-0445-44f9-90e6-7c4b3683be58%2Fyoy45jl_processed.png&w=3840&q=75)
Transcribed Image Text:# 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]
#
#
# 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
САРАСІTY - 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 / Gerrard 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 rent_bike (station_id: int, stations: List["Station"]) -> bool:
"""Update the available bike count and the docks available count
for the station in stations with id station_id as if a single bike was
removed, leaving an additional dock available. Return True if and only
if the rental was successful.
Precondition: station_id will appear in stations.
>>> with_bike_station = [7090, 'Danforth Ave / Lamb Ave', \
43.681991, -79.329455, 15, 4, 10]
>>> station_id = with_bike_station[ID]
>>> original_bikes_available = with_bike_station[BIKES_AVAILABLE]
>>> original_docks_available
>>> rent_bike(station_id, [with_bike_station])
with_bike_station[DOCKS_AVAILABLE]
True
>>> original_bikes_available
1 ==
with_bike_station[BIKES_AVAILABLE]
-
True
>>> original_docks_available + 1 ==
with_bike_station[DOCKS_AVAILABLE]
True
>>> no_bike_station
43.681991, -79.329455, 15, 0, 15]
>>> station_id = no_bike_station[ID]
>>> original_bikes_available = no_bike_station[BIKES_AVAILABLE]
>>> original_docks_available
>>> rent_bike(station_id, [no_bike_station])
[7090, 'Danforth Ave / Lamb Ave', \
no_bike_station[DOCKS_AVAILABLE]
False
>>> original_bikes_available
no_bike_station[BIKES_AVAILABLE]
==
True
>>> original_docks_available
no_bike_station[DOCKS_AVAILABLE]
True](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2597cbfd-8e09-416c-9d3e-8f104965bd19%2F9e927fc5-0445-44f9-90e6-7c4b3683be58%2Fe33qqhf_processed.png&w=3840&q=75)
Transcribed Image Text:def rent_bike (station_id: int, stations: List["Station"]) -> bool:
"""Update the available bike count and the docks available count
for the station in stations with id station_id as if a single bike was
removed, leaving an additional dock available. Return True if and only
if the rental was successful.
Precondition: station_id will appear in stations.
>>> with_bike_station = [7090, 'Danforth Ave / Lamb Ave', \
43.681991, -79.329455, 15, 4, 10]
>>> station_id = with_bike_station[ID]
>>> original_bikes_available = with_bike_station[BIKES_AVAILABLE]
>>> original_docks_available
>>> rent_bike(station_id, [with_bike_station])
with_bike_station[DOCKS_AVAILABLE]
True
>>> original_bikes_available
1 ==
with_bike_station[BIKES_AVAILABLE]
-
True
>>> original_docks_available + 1 ==
with_bike_station[DOCKS_AVAILABLE]
True
>>> no_bike_station
43.681991, -79.329455, 15, 0, 15]
>>> station_id = no_bike_station[ID]
>>> original_bikes_available = no_bike_station[BIKES_AVAILABLE]
>>> original_docks_available
>>> rent_bike(station_id, [no_bike_station])
[7090, 'Danforth Ave / Lamb Ave', \
no_bike_station[DOCKS_AVAILABLE]
False
>>> original_bikes_available
no_bike_station[BIKES_AVAILABLE]
==
True
>>> original_docks_available
no_bike_station[DOCKS_AVAILABLE]
True
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education