ProgrammingHardGATE CS · Product-company placement
What is printed on the first line?
What is printed on the first line?
n = -17 print(n >> 2, n // 4, n & 3, n % 4) print(n << 1, (n << 1) >> 1 == n, ~n)
- A. -5 -5 3 3
- B. -5 -4 3 3
- C. -4 -5 3 3
- D. -5 -5 3 -1
Correct answer: A. -5 -5 3 3
Right shift on a negative int floors, matching // 4. The low two bits of -17 are 11, so n & 3 and n % 4 both give 3.
More Python Programming questions
- What is printed on the first line? python x = 1 for in range(70): x = 2 print(x, x.bitlength(), x == 270) print(x.bitlength() - 1, (x…
- What is printed on the first line? python import math print(math.factorial(20) == 2432902008176640000, len(str(math.factorial(25))))…
- What is printed on the first line? python n = 264 print(n, n.bitlength(), hex(n - 1), oct(8), bin(5)) print(int(hex(n)[2:], 16) == n, -263…
- What is printed on the first line? python print(int('1' 19) + 1, 1018 10, 9223372036854775807 + 1 > 263 - 1) print(2100 // 298, (2100) >>…
- What is printed? python print(0b1111 ^ 0b1010 & 0b0110, (0b1111 ^ 0b1010) & 0b0110, 6 & 3 | 4 ^ 1)
- What is printed? python print(1 << 2 + 1, (1 << 2) + 1, 4 >> 1 - 1, 2 3 % 4 2 // 3)