Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1 Question 1 Write a function that takes in a list of tuples containing two elements and converts it into a dictionary. Return the

image text in transcribed

Problem 1 Question 1 Write a function that takes in a list of tuples containing two elements and converts it into a dictionary. Return the resulting dictionary. def list_to_dict(input_list): ### ### YOUR CODE HERE ### list_to_dict([('Chris', 'A'), ('John', 'A-'), ('Mia', 'A'), ('Emily', 'B'), ('David', 'B+')]) #{ 'Chris': 'A', 'John': 'A', 'Mia': 'A', 'Emily': 'B', 'David': 'B+'} ### AUTOGRADER TEST - DO NOT REMOVE ### AUTOGRADER TEST - DO NOT REMOVE Question 2 Write a function that takes a dictionary and a username(key) as inputs. Return the value stored at username passed in. If the name does not exist, return an error message def retrieve_grade (input_dictionary, name): ### YOUR CODE HERE ### print(retrieve_grade({'Chris': 'A', 'John': 'A', 'Mia': 'A', 'Emily': 'B', 'David': 'B+'},'John')) #A- print(retrieve_grade({'Chris': 'A', 'John': 'A', 'Mia': 'A', 'Emily': 'B', 'David': 'B+'},'Greg')) #Error: Greg not in grades ### AUTOGRADER TEST - DO NOT REMOVE ### AUTOGRADER TEST - DO NOT REMOVE

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions