Question: PYTHON Write a function that accepts a dictionary and a string as parameters; the dictionarys keys are students names, and the values are students ages;

PYTHON Write a function that accepts a dictionary and a string as parameters; the dictionarys keys are students names, and the values are students ages; the second parameter is a student name. The function should use the second parameter to search for students age in the dictionary; if the student exist in the dictionary, the function returns its age, otherwise, returns -1.Create a dictionary in your program and use it to test the function.You may use the below dictionary:{42: 'Marty', 81: 'Sue', 17: 'Ed', 31: 'Dave',56: 'Ed', 3: 'Marty', 29: 'Ed'}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!