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())
  1. A. 1,024 1_024 10000000000 -1024
  2. B. 1,024 400 10000000000 -1025
  3. C. 1,024 400 1024 -1024
  4. 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

Exams that ask this topic