Answered step by step
Verified Expert Solution
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
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
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