ProgrammingHardGATE CS & IT · Infosys
What is printed?
What is printed?
print(bin(5 ^ 3), int('101', 2) << 2, ~5, -~5)- A. 0b110 20 -5 5
- B. 0b101 20 -6 6
- C. 0b110 5 -6 6
- D. 0b110 20 -6 6
Correct answer: D. 0b110 20 -6 6
5 ^ 3 is 6, which prints as 0b110. ~5 is -6, and -~5 is -(-6) = 6. Shifting 5 left by two gives 20.
More Python Programming questions
- What is printed? python import math print(math.prod([]), math.prod([2, 3.0]))
- What is printed? python import heapq h = [1, 3] heapq.heapify(h) print(heapq.heapreplace(h, 0), sorted(h), heapq.heappushpop(h, 0)…
- What is printed? python try: print(list(zip([1, 2], [3], strict=True))) except ValueError: print('strict')
- What is printed? python print(round(1234, -2), round(1250, -2), round(1350, -2))
- What is printed? python def lcsub(a, b): best = end = 0 dp = [[0] (len(b) + 1) for in range(len(a) + 1)] for i in range(1, len(a) + 1)…
- A solution must decide whether a number n up to 10^12 is prime within about one second in CPython. Which approach is correct and fast…