ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
x = 10 print(x.bit_length(), (x >> 1).bit_length(), (x << 3) // 16)
- A. 4 4 5
- B. 3 3 5
- C. 4 3 10
- D. 4 3 5
Correct answer: D. 4 3 5
10 is 1010, which has 4 bits. 10 >> 1 is 5, which needs 3 bits. 10 << 3 is 80, and 80 // 16 is 5.
More Python Programming questions
- What is printed? python words = ['tea', 'eat', 'tan', 'ate', 'nat'] groups = {} for w in words: groups.setdefault(''.join(sorted(w))…
- What is printed? python print(0.2 + 0.4 + 0.1 == 0.7, 0.1 + (0.2 + 0.4) == 0.7, 0.2 + 0.1 + 0.4 == 0.7)
- What is printed? python print(sorted([(1, 'b'), (1, 'a'), (0, 'z')], reverse=True)[0])
- What is printed? python print(list(map(len, ['', 'ab', 'abc'])), sum(map(len, ['', 'ab', 'abc'])))
- What is printed? python print(10 in range(0, 20, 5), 11 in range(0, 20, 5))
- What is printed? python print(sum(range(1, 101)) 2 - sum(i i for i in range(1, 101)))