ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(len(bin(-1)), len(hex(255)), oct(64))
- A. 4 4 0o100
- B. 3 4 0o100
- C. 4 4 100
- D. 4 3 0o100
Correct answer: A. 4 4 0o100
bin(-1) is the four-character string -0b1, and hex(255) is 0xff with four characters. oct(64) is 0o100 with the 0o prefix.
More Python Programming questions
- What is printed? python print(int('12abc', 16), int('ABC', 16) == 0xabc, int('1000000') == 106)
- What is printed? python print('%s' % None, '%r' % None, '%d' % True)
- What is printed? python print(str(3) 2 + str(3 2), int(str(3) 2) + 3 2)
- What is printed? python print(10 // 3 3 + 10 % 3 == 10, -10 // 3 3 + -10 % 3 == -10)
- What is printed? python print(sum(int(d) for d in str(320)) % 9, 320 % 9, (320) % 10)
- What is printed? python print(len(str(1050 + 1).rstrip('0')), str(1050 + 1)[-2:], str(1050 - 1)[:3])