Q. What does the Python code: x = {1, 2, 3}; x.add(4); print(x) output?

A
{1, 2, 3, 4}
B
{1, 2, 3}
C
[1, 2, 3, 4]
D
Error
Solution:

The add() method adds an element to a set, so {1, 2, 3} with 4 added becomes {1, 2, 3, 4}.

Entri PDF Icon

Get Question Bank

Strengthen Your Practice with our comprehensive question bank.

Entri Contact Image

Get Expert Advice for Free: Register for Your Free Consultation Now!