Python Strings · Question 6 · Easy

An f-string is used to report Asha's marks. What exactly is printed?

name = "Asha"
marks = 91
print(f"{name} scored {marks + 1}")
  1. Asha scored 911
  2. {name} scored {marks + 1}
  3. Asha scored marks + 1
  4. Asha scored 92
Answer and explanation

Answer: D. Asha scored 92

Explanation: Inside an f-string, each pair of braces holds an expression that is evaluated and inserted as text. name gives Asha and marks + 1 is the integer sum 92.

Previous: The in operator tests two substrings of a city name. What does this print? · Next: In the slice s[a:b] of a string s, with a less than b, which characters are…

Practise python strings

Try a fresh set of python strings questions with an explanation after every answer, free and without signing up: Python Strings practice. Or sit a full placement mock test.

More python strings questions

More python practice

Lists & Tuples · Dictionaries & Sets · Conditions & Loops · Functions & Scope · Comprehensions & Generators · Classes & Objects · Exceptions & Files · Built-ins & Standard Library

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge