ProgrammingVery hardJEE Main · CAT placement
What is printed?
What is printed?
x = 0b1011 print(x & ~(1 << 1), x ^ (1 << 2), x | (1 << 4), (x >> 1) & 1)
- A. 9 15 27 1
- B. 11 15 27 1
- C. 9 7 27 1
- D. 9 15 27 0
Correct answer: A. 9 15 27 1
~(1 << 1) clears bit 1, so 1011 becomes 1001 = 9. XOR with bit 2 sets it to 1111 = 15, OR with bit 4 gives 27, and bit 1 of x after shifting is 1.
More Python Programming questions
- What is printed? python words = ['bb', 'a', 'ccc', 'aa'] print(sorted(words, key=lambda w: (-len(w), w)))
- What is printed? python pairs = [(1, 'b'), (1, 'a'), (0, 'c')] print(sorted(pairs, key=lambda p: p[0]), sorted(pairs))
- What is printed? python print(int('0b11', 0) + int('0o11', 0) + int('0x11', 0), int('11', 16), int('-0b11', 0))
- What is printed? python from math import inf print(inf - 1 == inf, 2 inf, -inf < -10 400, inf > 10 400)
- What is printed? python print(sum(1 for c in 'a1 b2' if c.isalpha()), sum(1 for c in 'a1 b2' if c.isdigit()), sum(c.isspace() for c in 'a1…
- What is printed? python print(round(2.675, 2), round(2.665, 2), round(1.0049999999999999, 3), round(-2.5, 0))