ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(bin(255)[2:].rjust(10, '0'), int('0b' + '1' * 8, 2) == 255, int('11111111', 2) + 0 == 255)- A. 11111111 True True
- B. 0011111111 False True
- C. 0011111111 True False
- D. 0011111111 True True
Correct answer: D. 0011111111 True True
rjust pads on the left to width 10 with zeros, and int accepts a 0b prefix when the base is 2. Both int conversions give 255.
More Python Programming questions
- What is printed? python s = 'hello world' print(s.count('o'), s.index('o', 5), s.title().split()[1][::-1])
- What is printed? python print(list(reversed(range(3))), list(range(3))[::-1] == list(reversed(range(3))), list(range(3, 0, -1)))
- What is printed? python print('Python'[::2], 'Python'[1::2], 'Python'[-2::-2])
- What is printed? python x = 3.0 print(x.isinteger(), (3.5).isinteger(), int(x) is x, type(int(x)).name)
- What is printed? python print(round(1e-20, 25) == 1e-20, round(123.456, 10), round(0.5 + 1e-17, 0))
- What is printed? python def f(s): return s.lower() == s[::-1].lower() print(f('Aba'), f('Ab'), f(''), f('A'))