ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
x = 0b1010 y = 0o17 z = 0xFF print(x ^ y, x | z, z >> 4, y & ~x)
- A. 5 127 15 5
- B. 5 255 15 15
- C. 5 255 15 5
- D. 21 255 15 5
Correct answer: C. 5 255 15 5
1010 XOR 1111 is 0101, which is 5. 1010 OR 11111111 is 255. 0xFF >> 4 is 15. ~10 is -11, and 15 & -11 keeps the low four bits 0101, which is 5.
More Python Programming questions
- What is printed? python a = 'Python' print(a[::-1][1:4], a[-2:] + a[:2], a.upper()[::2])
- What is printed? python n = 10 6 s = 0 i = 1 while i <= n: s += n // i i = 10 print(s)
- What is printed? python def matmul(A, B, m): return [[sum(A[i][k] B[k][j] for k in range(2)) % m for j in range(2)] for i in range(2)] def…
- What is printed? python n = 12 print(n & 1 == 0, (n & 1) == 0, n & n - 1 == 0, 8 & 7 == 0)
- What is printed on the first line? python print(pow(2, -1, 5), pow(3, -1, 7), pow(2, -3, 9)) try: print(pow(2, -1, 4)) except ValueError…
- What is printed? python import math print(math.comb(100, 50) % 1000, len(str(math.comb(100, 50))), math.perm(5, 2), math.comb(5, 7))