Bird
0
0

Find the error in this code:

medium📝 Debug Q6 of 15
Python - Input and Output
Find the error in this code:
age = 25
print(f"Age is {age:2d")
AInvalid format specifier :2d
BMissing f before string
CMissing closing brace } in f-string
DVariable age is not defined
Step-by-Step Solution
Solution:
  1. Step 1: Check f-string syntax

    Every opening brace { must have a matching closing brace }.
  2. Step 2: Identify missing brace

    The code has {age:2d but no closing } brace.
  3. Final Answer:

    Missing closing brace } in f-string -> Option C
  4. Quick Check:

    All braces must be closed in f-strings [OK]
Quick Trick: Always close braces {} in f-strings [OK]
Common Mistakes:
MISTAKES
  • Forgetting closing brace
  • Using wrong format specifier
  • Missing f prefix

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes