O get_index(dictionary, list) takes two input arguments, a dictionary (crime_dict) and a list of strings (keywords). This function searches if any crime type matches at least one of the keywords provided in that input list (note: keywords are not case sensitive and any partial matches are allowed). For every valid search result, this function stores the index of the crime type to another ID-list, and finally returms this list. If no matches are found, your function should return an empty list. See sample outputs below. result - get_index(crime_dict, ["ar", "break", "theft"]) ) print(result) (3, 4, 8, 9, 10] result = get index(crine_dict, ["misc", "theft over", "break"]) ) print(result) [6, 10, 4] result get index(crime_dict, ["homicide", "shooting"])) print(result) Page 7 of 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
icon
Related questions
Question
(i) get_index(dictionary, list) takes two input arguments, a dictionary
(crime_dict) and a list of strings (keywords). This function searches if any crime type
matches at least one of the keywords provided in that input list (note: keywords are not
case sensitive and any partial matches are allowed). For every valid search result, this
function stores the index of the crime type to another 1D-list, and finally returns this list.
If no matches are found, your function should return an empty list. See sample outputs
below.
result = get_index(crime_dict, ["ar", "break", "theft"]) )
print(result)
[3, 4, 8, 9, 10]
result = get_index(crime_dict, ["misc", "theft over", "break"]) )
print(result)
[6, 10, 4]
result = get_index(crime_dict, ["homicide", "shooting"]))
print(result)
Page 7 of 10
ssignment # 4
Due: Nov. 27* 10:00 PM EST
0) get_crimes_in_range(adict, 20list, 1Dlist, high, low) takes five input
arguments as follows, a dictionary (crime_dict), a 2D-list (database), a ID-list of
strings (keywords), and two positive integer values, high and low, with high > low.
The last argument low has a default value 0. This function searches, for any crime type that
matches any of the given keywords, if the total number of crimes of this type falls between
the range (high, low] inclusive. Partial matches are allowed, and the keywords are not case
sensitive. For cach such valid search, the function stores the results in a 2D-list in the
following format:
[[crime type 1, total crimes of this type], [crime type 2, total crimes
of this type], ].
If there is no keyword that matches a crime type or there is no data in the given range, this
list should be empty. Your function should return this 2D-list. See the sample outputs for
examples.
list = get_crimes_in_range(crime_dict, database, ["theft", "ar"], 15000,
100) )
display_2D1ist(list)
['Theft - Motor Vehicle', 168]
['Theft $5000 and Under', 4793]
list = get_crimes_in_range(crime_dict, database, ["theft", "ar"], 15e0e,
100) )
display_2Dlist(list)
['Theft - Motor Vehicle', 168]
['Theft $5000 and Under', 4793]
['Theft Over $5000', 96]
['Arson', 10]
list = get_crimes_in_range(crime_dict, database, ["theft"], 5) )
display_20list(list)
No data in list
Transcribed Image Text:(i) get_index(dictionary, list) takes two input arguments, a dictionary (crime_dict) and a list of strings (keywords). This function searches if any crime type matches at least one of the keywords provided in that input list (note: keywords are not case sensitive and any partial matches are allowed). For every valid search result, this function stores the index of the crime type to another 1D-list, and finally returns this list. If no matches are found, your function should return an empty list. See sample outputs below. result = get_index(crime_dict, ["ar", "break", "theft"]) ) print(result) [3, 4, 8, 9, 10] result = get_index(crime_dict, ["misc", "theft over", "break"]) ) print(result) [6, 10, 4] result = get_index(crime_dict, ["homicide", "shooting"])) print(result) Page 7 of 10 ssignment # 4 Due: Nov. 27* 10:00 PM EST 0) get_crimes_in_range(adict, 20list, 1Dlist, high, low) takes five input arguments as follows, a dictionary (crime_dict), a 2D-list (database), a ID-list of strings (keywords), and two positive integer values, high and low, with high > low. The last argument low has a default value 0. This function searches, for any crime type that matches any of the given keywords, if the total number of crimes of this type falls between the range (high, low] inclusive. Partial matches are allowed, and the keywords are not case sensitive. For cach such valid search, the function stores the results in a 2D-list in the following format: [[crime type 1, total crimes of this type], [crime type 2, total crimes of this type], ]. If there is no keyword that matches a crime type or there is no data in the given range, this list should be empty. Your function should return this 2D-list. See the sample outputs for examples. list = get_crimes_in_range(crime_dict, database, ["theft", "ar"], 15000, 100) ) display_2D1ist(list) ['Theft - Motor Vehicle', 168] ['Theft $5000 and Under', 4793] list = get_crimes_in_range(crime_dict, database, ["theft", "ar"], 15e0e, 100) ) display_2Dlist(list) ['Theft - Motor Vehicle', 168] ['Theft $5000 and Under', 4793] ['Theft Over $5000', 96] ['Arson', 10] list = get_crimes_in_range(crime_dict, database, ["theft"], 5) ) display_20list(list) No data in list
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Linked List Representation
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education