ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(bin(10)[::-1], int(''.join(reversed(bin(10)[2:])), 2), format(10, 'b').zfill(6))- A. 0101b0 5 001010
- B. 0101b0 10 001010
- C. 0b1010 5 001010
- D. 0101b0 5 10
Correct answer: A. 0101b0 5 001010
Reversing the string '0b1010' gives '0101b0'. Reversing only the digits 1010 gives 0101, which is 5, and format with zfill pads 1010 to six places.
More Python Programming questions
- What is printed? python from collections import Counter c = Counter(a=1) c.subtract({'a': 3, 'b': 1}) print(c, c['a'] + c['b'])
- What is printed? python print(sorted([(2, 'b'), (1, 'z'), (3, 'a')], reverse=True))
- What is printed? python print(3 in {1, 2, 3} and 'x' in 'xyz', [] or () or None)
- What is printed? python def flat(x): for i in x: if isinstance(i, list): yield from flat(i) else: yield i print(list(flat([1, [2, [3, 4]]…
- What is printed? python print('42'.zfill(5), '-42'.zfill(5), 'ab'.center(6, ''), 'x'.ljust(3, '.') + '|')
- What is printed? python print(10 / 2, 10 // 2, 7 / 7, 2 3 + 4)