Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Carefully study the code shown below. When run, this code could potentially produce at least 2 different errors. You should identify specifically the line number and location where each of these errors could occur and you should explain HOW and WHY it would occur.
1 def run_the_code(countries):
''' You can expect countries to be a dictionary with 0 or more string keys mapped to int values. '''
4 if len(countries) > 20:
print(countries['russia'])
6 for country in countries:
elif countries[country] > 10000:
print(country + 10000)
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 nowThis is a popular solution!
Step by stepSolved in 2 steps with 2 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.Similar questions
- This is my code for a dictionary of student's test scores. def main(): #Create a dictionary with name as key #Marks as the list of values student_dictionary = \ { 'Brian': [94, 89, 92], 'Rachel': [100,90,65], 'Jon': [67.5,95,100], 'Brit': [0,78,80] , 'Gret': [65,100,78], 'Andrea': [55.5,67,79] } for key in student_dictionary.keys(): print('Name: ', key, " , Marks:", student_dictionary.get(key)) if __name__ == '__main__': main() Problem: Find and print out Rachels second score (should be a 90)arrow_forwardGiven a dictionary, my_dict = {'a':5, 'b':45, 'c': 60, 'd':99, 'e':199,'f':0} write a python program to find the minimum and maximum values from the dictionary.arrow_forward‘Write a program to maintain grades for a class. The program will repeatedly prompt the user with the following menu, and use functions to perform the tasks ofuser's choice. Exit 1. Enter student info 2. Print grades for a student 3. Print class max, min, and average grades The program should use a dictionary to keep information about a student, including the student names and grades for three exams: midterm 1, midterm 2 andfinal exam. Assume the grades are positive integers between 0 and 100. The program should keep information about the students in a list for the entire class. ‘Assample run of the program is as follows. Exit 1. Enter student info 2. Print grades for a student 3. Print class max, min, and average grades Enter your choice: 1 Do you want to enter student info (y/n):Enter the student name: Adams Enter midterm 1 grade: 85 Enter midterm 2 grade: 87 Enter final exam grade: 90 Do you want to enter student info (y/n!Enter the student name: Mary Enter midterm 1 grade: 78 Enter…arrow_forward
- Question Completion Status: 3 P QUESTION 6 Implement the following: 1) Create a dictionary from the following data (the key is the name and the value is the age): Ann 53 Bill 24 Calvin 36 David 25 2) Use a loop to print all ages on the same line and separated by a space. 3) In the loop above, calculate the average age with a precision of two decimal places. 4) Print the average. Do not just print(34.5). Just make sure to precisely match the output format below. Write your code in the ANSWER area provided below (must include comments if using code is not covered in the course). Example Output 53 24 36 25 Average: 34.50 For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). B IUS Paragraph Arial V Programs 10pt Click Save and Submit to save and submit. Click Save All Answers to save all answers. !!! 描く Aarrow_forwardAssume that d refers to a dictionary. Write a statement in Python that retrieves from the dictionary the value that is associated with the key 'answer', and assigns this value to the result variable.arrow_forwardIn Python:arrow_forward
- QUESTION 8 Which of the following is not a declaration of the dictionary? A. {1, "A", 2"B"} B. dict([[1, "A"],[2,"B"]]) C. {} D. {1: 'A', 2: 'B'}arrow_forwardneed help with python...paste indented code here... QUESTION 6 Implement the following: a) Create a dictionary, grades, and initialize it with the following data:'Jimmy': 66 'Jerry': 80'Jacob': 71'James': 59'Jenny': 90 b) Use a loop to print all items of the dictionary grades as follows:name receives grade A (if the value is 90 or above).name receives grade B (if the value is 80 or above).name receives grade C (if the value is 70 or above).name receives grade D (if the value is 60 or above).name receives grade F (if the value is below 60). Example OutputJimmy receives grade D.Jerry receives grade B.Jacob receives grade C.James receives grade F.Jenny receives grade A.arrow_forwardPYTHON prov_records_per_date() takes a 2-D list (similar to the database) and an integer representing the province ID. This function returns another 2-D list, where each element of this list stores information in the following format. [ [day1, total number of patients (both icu and non-icu) in this provice reported in day1], [day2, total number of patients (both icu and non-icu) in this provice reported in day2], ... ] >>> results = prov_records_per_date(database, 35) >>> display_dict(result) >>> display_list(result) ['2022-01-31', 239] ['2022-02-05', 393] >>> results = prov_records_per_date(database, 10) >>> display_dict(result)['2022-02-02', 225] >>> results = prov_records_per_date(database, 81) >>> display_dict(result)No data in listarrow_forward
- create a function in python parameters: 1. dict[str, list[str]] 2. list[str] return type: dict[str, list[str]] must do like this: 1. establish an empty dictionary that will serve as the dictionary returned at the end 2. loop thorugh each of the columns in the second parameter of the function 2a. asssign to the column key of the result dictionary the list of values stored in the input dictionary at the same column 3. return the dictionary produced do not import other libraries such as pandas, .select, .head, .iloc or anything this function is being used to work in a dataframearrow_forwardPythonarrow_forwardThe function below, get_value_if_key, takes two arguments: the dictionary data_dict and a key of any type my_key. Fix the code to return the value from data_dict for key my_key if that key exists. The function should not return anything otherwise (i.e. return None).arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
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