LearnFrenzy
Sign in Take a free test

Sets · Sets MCQ · Question 15

A set comprehension Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 15 Back to Exercise

Which expression is a set comprehension?

  • A [x * 2 for x in nums]
  • B {x * 2 for x in nums} Correct
  • C {x: x * 2 for x in nums}
  • D (x * 2 for x in nums)
Correct Answer: Option B

Braces with a single expression make a set; with key: value they make a dict; square brackets a list; round brackets a generator.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links