ProgrammingVery hardJEE Main · CAT placement
What is printed?
What is printed?
x = 0b10110110 print(format(x, '08b')[::-1], x.bit_count(), x & (x - 1), (x & -x).bit_length())
- A. 10110110 5 180 2
- B. 01101101 5 180 1
- C. 01101101 5 180 2
- D. 01101101 4 180 2
Correct answer: C. 01101101 5 180 2
Reversing the eight-bit string gives 01101101. x has five set bits, x & (x - 1) clears the lowest set bit (value 2), and the lowest set bit is 2, which has bit length 2.
More Python Programming questions
- What is printed? python print(f'{1:>{3}}', '{0[1]}-{1!r}'.format('ab', 'cd'), '{0!r:>6}'.format('x'), '{:.1%}'.format(0.256))
- What is printed? python x = 232 + 5 print((x 0x9E3779B1) & 0xFFFFFFFF, (5 0x9E3779B1) & 0xFFFFFFFF)
- What is printed? python import math print(math.factorial(20) // 106 % 1000, len(str(math.factorial(30)))…
- What is printed? python print(float('0.1') == 0.1, float(' 0.1 ') == 0.1, 0.1 == float(str(0.1)), 1e23 == 1023)
- What is printed? python total = 0 for s in ['10', '9', ' x', '+7', '10']: try: total += int(s) except ValueError: total -= 1 print(total)
- What is printed? python print('%d' % 3.9, '%d' % -3.9, '%.0f' % 0.5, '%i' % True)