Bird
Raised Fist0

What will this code print?

medium📝 Predict Output Q5 of Q15
Python - Standard Library Usage
What will this code print?
from datetime import datetime
birthday = datetime(1990, 7, 20)
print(birthday.strftime('%d/%m/%Y'))
A07/20/1990
B20/07/1990
C1990/07/20
D20-07-1990
Step-by-Step Solution
Solution:
  1. Step 1: Understand strftime format codes

    %d = day with leading zero, %m = month with leading zero, %Y = 4-digit year.
  2. Step 2: Apply format to birthday date

    Day=20, Month=07, Year=1990, formatted as '20/07/1990'.
  3. Final Answer:

    20/07/1990 -> Option B
  4. Quick Check:

    strftime formats date as specified [OK]
Quick Trick: Use %d/%m/%Y for day/month/year format [OK]
Common Mistakes:
MISTAKES
  • Mixing up %m and %d
  • Using wrong separators
  • Confusing year format codes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes