Question
Question from Python for ArcGIS textbook by Laura Tateosian: The following script has a tide gauge dictionary tides = {'G1': [1,6], 'G2': [2], 'G3': [3,8,9]}.
Question from Python for ArcGIS textbook by Laura Tateosian:
The following script has a tide gauge dictionary tides = {'G1': [1,6], 'G2': [2], 'G3': [3,8,9]}. The dictionary currently stores tide gauge readings for three gauges, G1, G2, and G3. Notice that each value in the dictionary is a Python list, so that one or more readings can be recorded for each gauge. Whenever a new item is added to the dictionary, the value must be a Python list, so that the item can store multiple readings for that gauge. Use dictionary operations to reflect each of the following events and print the dictionary after each step:
a) A new gauge, G5, has been installed and the first reading was 2.
b) Record an additional reading for gauge G5, the number 6.
c) The latest reading from gauge G3 is invalid. Discard this information using the list pop() method.
d) A new gauge G6 has been installed but no readings are recorded yet. Use an empty list as a placeholder.
e) Gauge G3 is no longer collecting data. Remove the item that represents this gauge.
f) Gauge G1 recorded measurements two times higher than they should be. Use list comprehension to correct this error.
Script:
# tideRecords.py # Purpose: Practice performing dictionary operations. # Usage: No arguments needed.
tides = {'G1': [1, 6], 'G2': [2], 'G3': [3, 8, 9]}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started