ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print(int.bit_length(-255), (255).bit_length(), (256).bit_length())
- A. 8 8 8
- B. 9 8 9
- C. 8 8 9
- D. 7 8 9
Correct answer: C. 8 8 9
bit_length works on the absolute value, so -255 needs 8 bits. 255 fits in 8 bits, while 256 needs 9.
More Python Programming questions
- What is printed? python print(chr(0x1F600) == '😀', len('😀'), len('😀'.encode('utf-16-le')))
- What is printed? python print(10400 > float('inf'), float('inf') > 10400, float(10308) == 10308)
- What is printed? python print('ab' in ['a', 'ab'], 'ab' in 'a,ab'.split(','), 'a' in 'abc' and 'ac' in 'abc')
- What is printed? python print(f'{-5:x}', f'{-5 & 0xF:x}', hex(-255), format(255, '#010b'))
- What is printed? python students = [('Ravi', 88), ('Asha', 92), ('Bala', 88), ('Chitra', 92)] print([n for n, s in sorted(students…
- What is printed? python print('Hello'[1:3] + 'Hello'[-1], len('Hello'[10:]), 'Hello'[::2])