ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(hex(255), oct(8), bin(-5))
- A. 0xff 0o11 -0b101
- B. 0xff 010 -0b101
- C. 0xff 0o10 -101
- D. 0xff 0o10 -0b101
Correct answer: D. 0xff 0o10 -0b101
hex and oct use lowercase digits with the prefixes 0x and 0o, and bin of a negative number puts the minus sign before the 0b prefix.
More Python Programming questions
- What is printed? python print(chr(0x41), ord('n'))
- What is printed? python from collections import Counter a = [1, 1, 2, 3, 3] c = Counter(a) print(sum(c[x] c[4 - x] for x in c))
- What is printed? python def nlis(a): n = len(a) L = [1] n C = [1] n for i in range(n): for j in range(i): if a[j] < a[i]: if L[j] + 1 >…
- What is printed? python print(bin(29 ^ 15).count('1'))
- What is printed? python from functools import lrucache @lrucache(maxsize=None) def p(n, m): if n == 0: return 1 if n < 0 or m == 0: return…
- What is printed? python import math print(sum(map(int, str(math.factorial(10)))))