Search for question
Question

CSEN 2304 Introduction to Computer Science Spring 2024 This is an extra credit assignment. It is not part of the required assignments for the course. As discussed in class, there are many places in Python where the “in” operator can be used to check for membership of an item within a collection or data structure. Recently the use of the "in" operator with Python dictionaries was examine. For this extra credit assignment you are to write a Python function that can perform the same operation as the "in" operator for dictionaries. Specifically, you are to write a Python function that accepts two parameters. The first parameter should be a dictionary (d) and the second should be a key (k). The function should simulate the Python "in" operator by checking to see if the key k is present in the dictionary d. Importantly, the function should do this without the use of the "in" operator itself (since the purpose of the assignment is to simulate the "in" operator). A return bool return value of True should be sent back to the calling code if the key k is present in the dictionary d, a False bool value should be returned otherwise. Test the function by calling it from the main body of code and printing the result to ensure it works correctly.