ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
x = 5
print(f'{x=}', f'{x * 2 = }', f'{"a" * 2!r}')
  1. A. x=5 x * 2 = 10 'a'
  2. B. 5 10 'aa'
  3. C. x=5 x * 2 = 10 'aa'
  4. D. x=5 x * 2 = 20 'aa'

Correct answer: C. x=5 x * 2 = 10 'aa'

The = specifier in an f-string prints the expression text, an equals sign and the repr of the value. !r then shows the string with quotes.

More Python Programming questions

Exams that ask this topic