Question Detail

COS 102 Advanced Text Processing Objective Question

Question

Given `name = "Tolani"` and `score = 85`, what will be the output of `print(f"Hello {name}, your score is {score}.")`?
Options
A Hello {name}, your score is {score}.
B Hello name, your score is score.
C Hello Tolani, your score is 85.
Correct Answer
D Error: f-string syntax.
Correct Answer

Option C is the correct answer.

Detailed Explanation

f-strings embed variables directly into the string by placing them inside curly braces {}. The 'f' prefix before the string literal activates this behavior. So, {name} becomes 'Tolani' and {score} becomes '85'.

Hint

f-strings automatically substitute variables within curly braces.

Question Info