Dictionaries & Sets · Question 17 · Hard
Sets are built from the letters of two words. What is printed?
print(set("hello") == set("hole"), len(set("hello")))
- False 4
- True 5
- True 4
- False 5
Answer and explanation
Answer: C. True 4
Explanation: A set keeps each letter once and ignores order. "hello" gives the letters h, e, l, o, which is exactly the set built from "hole", so they are equal and the length is 4.
Previous: An int, a float and a bool are used as keys in one dictionary literal. What… · Next: New keys are added to a dictionary inside a for loop over the same dictionary…
Practise dictionaries & sets
Try a fresh set of dictionaries & sets questions with an explanation after every answer, free and without signing up: Dictionaries & Sets practice. Or sit a full placement mock test.
More dictionaries & sets questions
- Which of the following values can be used as a dictionary key?
- pop() is called for a key that exists and for one that does not. What does…
- An int, a float and a bool are used as keys in one dictionary literal. What…
- New keys are added to a dictionary inside a for loop over the same dictionary…
- A keys view is taken before the dictionary is changed. What does this print?
- A grade dictionary is inverted with a comprehension. What is printed?
More python practice
Conditions & Loops · Functions & Scope · Comprehensions & Generators · Classes & Objects · Exceptions & Files · Built-ins & Standard Library · Variables, Types & Operators · Python Strings
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge