Practice mode Python

Which expression creates an empty set in Python?

Correct answer B. set()

Explanation

Curly braces with nothing inside create an empty dictionary, not a set, because dict literals came first. The only way to create an empty set is to call set(). Non-empty sets can use braces, as in {1, 2}, while [] is an empty list and () is an empty tuple.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.