ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(f'{2**10:,}', f'{2**10:_x}', f'{2**10:b}', f'{-2**10:>8}'.strip())- A. 1,024 1_024 10000000000 -1024
- B. 1,024 400 10000000000 -1025
- C. 1,024 400 1024 -1024
- D. 1,024 400 10000000000 -1024
Correct answer: D. 1,024 400 10000000000 -1024
The comma flag groups thousands, and _x prints hex with an underscore separator, giving 400 for 1024. Binary 1024 is a 1 followed by ten zeros, and the -1024 string is padded then stripped.
More Python Programming questions
- What is printed? python print(str(round(2.5)), str(round(3.5)), round(2.5 + 0.0001), round(-2.5 - 0.0001))
- What is printed? python s = 'ab' 2 + 'c' print(s.endswith('bc'), s.startswith('ab', 2), s.find('ab', 1), s.count('ab'))
- What is printed? python print(len(''.join(str(i) for i in range(1, 11))), ''.join(str(i) for i in range(1, 11))[-3:], sum(len(str(i)) for…
- What is the time complexity of checking whether a number n is prime by trial division up to its square root?
- What is printed? python from string import Template print(Template('a-b').substitute(a=1, b=2), Template('ac').safesubstitute(a='x')…
- What is printed? python try: print((300).tobytes(1, 'big')) except OverflowError: print('overflow') print((255).tobytes(1, 'big')…