ProgrammingModerateInfosys · Accenture · Capgemini pattern
What is printed?
What is printed?
print({1, 2, 3} ^ {2, 3, 4}, {1, 2} <= {1, 2, 3})- A. {1, 4} True
- B. {1, 4} False
- C. {1, 2, 3, 4} True
- D. {2, 3} True
Correct answer: A. {1, 4} True
^ is symmetric difference: the elements in exactly one of the sets, here {1, 4}. <= tests for subset, and {1, 2} is a subset of {1, 2, 3}, so it is True.
More Python Programming questions
- What is printed? python a = "abc" b = a a += "d" print(a, b)
- What is printed? python t = (1, [2, 3]) t[1].append(4) print(t)
- What is printed? python print(0.1 + 0.2 == 0.3, abs(0.1 + 0.2 - 0.3) < 1e-9)
- What is printed? python def outer(): n = 0 def inc(): nonlocal n n += 1 return n return inc c = outer() c(); c() print(c())
- What is printed? python print([1, 2, 3], sep="-", end="!n")
- What is printed? python print("%d items" % 3.9, int("0x1A", 16))