Question 9
Back to Exercise
What is the output of the following Python program?
name = "Asha"
marks = 91.456
print(f"{name} scored {marks:.1f}")
print(f"{name!r:>8}|")
- A Asha scored 91.5 'Asha'| Correct
- B Asha scored 91.4 'Asha'|
- C Asha scored 91.5 Asha|
- D Asha scored 91.456 'Asha' |
Correct Answer: Option A
.1f rounds to one decimal (91.5). !r uses repr(), which adds quotes, and >8 right-aligns the 6-character result in 8 places.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!