ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(bin(12345).count('1'), len(bin(12345)) - 2)- A. 7 14
- B. 5 14
- C. 6 14
- D. 6 13
Correct answer: C. 6 14
12345 = 8192 + 4096 + 32 + 16 + 8 + 1, which has six 1-bits. Its binary form 0b11000000111001 has 14 digits, so len(bin(...)) - 2 is 14.
More Python Programming questions
- What is printed? python print(int(float('1e3')), int('12'))
- What is printed? python print('%5.2f|%-4d|%04x' % (3.14159, 7, 255))
- What is printed? python a = {1, 2, 3, 4} b = {3, 4, 5} print(a ^ b, a - b, b <= a, a | b == {1, 2, 3, 4, 5})
- What is printed? python print(int(2.675 100), round(2.675, 2))
- What is printed? python print(-7.5 // 2, -7.5 % 2)
- What is printed? python print(pow(3, 0, 1), pow(3, 0), 0 0)