ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
a = {1, 2, 3, 4}
b = {3, 4, 5}
print(a ^ b, a - b, b <= a, a | b == {1, 2, 3, 4, 5})- A. {1, 2, 5} {1, 2, 3, 4} False True
- B. {1, 2, 5} {1, 2} False True
- C. {3, 4} {1, 2} False True
- D. {1, 2, 5} {1, 2} True False
Correct answer: B. {1, 2, 5} {1, 2} False True
^ is symmetric difference, giving {1, 2, 5}. a - b keeps {1, 2}. b is not a subset of a because 5 is missing, and the union equals {1, 2, 3, 4, 5}.
More Python Programming questions
- What is printed? python print(int(2.675 100), round(2.675, 2))
- What is printed? python print(-7.5 // 2, -7.5 % 2)
- What is printed? python print(pow(3, 0, 1), pow(3, 0), 0 0)
- What is printed? python x = [1, 2, 3, 4, 5] print(x[-1:-4:-1], x[::-1][:2], x[::2][-1])
- What is printed? python import bisect a = [3, 1, 2, 5, 4] seen = [] inv = 0 for x in a: inv += len(seen) - bisect.bisectright(seen, x)…
- What is printed? python print(float('nan') == float('nan'), float('inf') - float('inf') != float('inf') - float('inf'))