ProgrammingVery hardCAT · MBA placement

What is printed?

What is printed?
print(f'{7:03d}|{-7:d}|')
  1. A. 007|-7|
  2. B. 010|-7|
  3. C. 007|-07|
  4. D. 7|-7|

Correct answer: A. 007|-7|

The 03d spec zero-pads the integer to width three, and a negative value keeps its minus sign in the output.

More Python Programming questions

Exams that ask this topic