What will list(d.keys()) return?
d = {'A': 1, 'B': 2, 'C': 3}

Practice More Questions From: Quiz 7 – Dictionaries

Q:

What’s the result of the following code? my_list = [‘cat’, ‘dog’, ‘fish’] print(‘cat’ in my_list)

Q:

What will list(d.keys()) return? d = {‘A’: 1, ‘B’: 2, ‘C’: 3}

Q:

How would one delete the entry with key ‘A’? d = {‘A’: 1, ‘B’: 2, ‘C’: 3}

Q:

What is the result of the following code? d = {} d[1] = 1 d[‘1’] = 2 d[1] = 3 sum = 0 for i in d: sum += d[i] print(sum)

Q:

What is the result of the following code? course = {‘1’: ‘CIT590’, ‘2’: ‘CIT591’, ‘3’: ‘CIT593’} print(course[‘1’])

Q:

What is the result of the following code? course = {‘1’: ‘CIT590’, ‘2’: ‘CIT591’, ‘3’: ‘CIT593’} print(course[‘4’])

Q:

What is the result of the following code? course = {‘1’: ‘CIT590’, ‘2’: ‘CIT591’, ‘3’: ‘CIT593’} print(course.get(‘4’))

Q:

What is the result of the following code? course = {‘1’: ‘CIT590’, ‘2’: ‘CIT591’, ‘3’: ‘CIT593’} print(course.get(‘4’, ‘CIT594’))

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments