ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(0b1 << 100 > 2**99, (1 << 100).bit_length(), len(bin(1 << 100)) - 2)
- A. False 101 101
- B. True 100 101
- C. True 101 101
- D. True 101 100
Correct answer: C. True 101 101
1 << 100 is 2**100, which is above 2**99. The number 2**100 needs 101 bits, and bin() prints '0b' followed by 101 digits.
More Python Programming questions
- What is printed? python print(float(3) / 2 == 1.5, 3 // 2.0, 3 / 2.0 // 1)
- What is printed? python print(round(3.14159, 3), round(2.5e-7, 7), round(123.456, -1), round(-0.0001, 2))
- What is printed? python print('Hello World'.swapcase().title(), 'tEST'.capitalize(), 'x'.isalpha(), '1.5'.isdigit(), '١٢'.isdigit())
- What is printed? python print('ab' in 'cabd', '' in 'abc', 'abc'.index(''), len('abc'[3:]), len('abc'[4:]))
- What is printed? python print(sum(map(int, str(220))), len(str(350)), str(105)[::-1].count('0'))
- What is printed? python print(float('0.1') + float('0.2') == float('0.30000000000000004'), 0.1 + 0.2 == 0.30000000000000004)