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")))
  1. False 4
  2. True 5
  3. True 4
  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

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