ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print('%o' % 8 == oct(8)[2:], '%x' % 255 == hex(255)[2:], bin(5)[2:].zfill(4))- A. True True 0101
- B. True False 0101
- C. True True 101
- D. False True 0101
Correct answer: A. True True 0101
%o and oct() both give octal digits, and %x and hex() both give lowercase hexadecimal digits. bin(5) is 101, which zfill pads to 0101.
More Python Programming questions
- What is printed? python print(-1 2, (-1) 2, -1 -1, (-1) -1)
- What is printed? python print(divmod(-9, 4), divmod(9, -4), -9 % 4, 9 % -4)
- What is printed? python class C: k = 10 try: a = [k + x for x in range(3)] except NameError: a = 'NameError' print(C.a)
- What is printed? python a = [1, 2, 3, 4] a[1:3] = [9] print(a) b = [1, 2, 3, 4] try: b[::2] = [0] except ValueError: print('ValueError')
- What is printed? python from collections import Counter def ways(a, t): dp = Counter({0: 1}) for x in a: nd = Counter(dp) for s, c in…
- What is printed? python print(bin(5 ^ 3), int('101', 2) << 2, ~5, -~5)