ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(bin(37).count('1'), bin(37)[2:].count('0'), (37).bit_length() - bin(37).count('1'))- A. 3 2 3
- B. 3 3 3
- C. 3 3 2
- D. 4 2 3
Correct answer: B. 3 3 3
37 is 100101 in binary, which has three ones and three zeros. Its bit length is 6, so bit length minus the ones count is also 3.
More Python Programming questions
- What is printed? python x, count = 0b1011011, 0 while x: x &= x - 1 count += 1 print(count, bin(0b1011011).count('1'))
- What is printed? python def isanagram(a, b): return sorted(a) == sorted(b) print(isanagram('listen', 'silent'), isanagram('abc', 'abcc')…
- What is printed? python print(pow(3, 1018, 7), pow(3, 6, 7), pow(3, 1018 % 6, 7))
- What is printed? python print(sum(range(10)) / len(range(10)), sum(range(10)) // len(range(10)), sum(range(1, 11)) % 7)
- What is printed? python n = 12345 print(n // 10 3 % 10, n % 10 3 // 100, str(n)[1], n // 1000 % 10 == int(str(n)[1]))
- What is printed? python import math print(math.gcd(240 - 1, 220 - 1) == 220 - 1, math.lcm(12, 18) == 36, math.gcd(1030, 1020) == 1020)