350-401 · Question #944
What is displayed when the code is run?
The correct answer is C. The answer is 25. The Python code performs an arithmetic calculation and then embeds the result into an f-string for printing.
Question
Exhibits
Options
- AThe answer is 100
- BThe answer is 5
- CThe answer is 25
- DThe answer is 70
How the community answered
(60 responses)- A15% (9)
- B7% (4)
- C75% (45)
- D3% (2)
Why each option
The Python code performs an arithmetic calculation and then embeds the result into an f-string for printing.
The calculation `x * y / 2` is `5 * 10 / 2 = 25`, not 100.
The calculation `x * y / 2` is `5 * 10 / 2 = 25`, not 5.
The expression `x * y / 2` evaluates to `5 * 10 / 2`, which is `50 / 2 = 25.0`. The f-string then formats this result as 'The answer is 25.0', which is typically represented as 'The answer is 25' in contexts where the decimal zero is omitted.
The calculation `x * y / 2` is `5 * 10 / 2 = 25`, not 70.
Concept tested: Python f-strings and arithmetic operations
Source: https://docs.python.org/3/tutorial/inputoutput.html#formatted-string-literals
Topics
Community Discussion
No community discussion yet for this question.

