Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

What will be the result of len({'a': 1, 'b': 2, 'c': 3})?

View

How can you safely remove a key from a dictionary?

View

Which method clears all elements from a dictionary?

View

What does dict1.update(dict2) do?

View

How can you check if a key exists in a dictionary?

View

What is the output of {1: 'a', 2: 'b'}[1]?

View

Can a dictionary have duplicate keys?

View

What is the result of {1: 'x', 2: 'y'}[3]?

View

Which method returns a list of dictionary’s key-value tuples?

View

Can a dictionary key be a list?

View

What will be the result of len({'a': 1, 'b': 2, 'c': 3})?

1
2
3
4

How can you safely remove a key from a dictionary?

del dict[key]
dict.pop(key)
dict.remove(key)
Both a and b

Which method clears all elements from a dictionary?

delete()
clear()
remove()
reset()

What does dict1.update(dict2) do?

Replaces dict1 with dict2
Updates dict1 with dict2’s key-value pairs
Merges two dictionaries into a new one
Removes duplicates from dict1

How can you check if a key exists in a dictionary?

key in dict
dict.has_key(key)
dict.contains(key)
key.is_present(dict)

What is the output of {1: 'a', 2: 'b'}[1]?

1
'a'
'b'
Error

Can a dictionary have duplicate keys?

Yes
No
Only if the values are the same
It depends on the key type

What is the result of {1: 'x', 2: 'y'}[3]?

'x'
KeyError
None
'y'

Which method returns a list of dictionary’s key-value tuples?

dict.keys()
dict.values()
dict.items()
dict.entries()

Can a dictionary key be a list?

Yes
No
Only if the list is converted to a tuple
It depends on the list length