MCQ Answer

<p>What does the following code do?</p><pre><span style="font-size: 14px;">from datetime import datetime<br></span><span style="font-size: 14px;">dt = datetime.strptime("2024-11-22", "%Y-%m-%d")<br></span><span style="font-size: 14px;">print(dt)</span></pre>

What does the following code do?

from datetime import datetime
dt = datetime.strptime("2024-11-22", "%Y-%m-%d")
print(dt)


नीचे दिए गए code का output क्या है?

from datetime import datetime
dt = datetime.strptime("2024-11-22", "%Y-%m-%d")
print(dt)
Topic : Modules in Python

A. Returns the current date

B. Converts the string "2024-11-22" to a datetime object

C. Returns the string "2024-11-22"

D. Raises a ValueError




Correct Answer is :

B. Converts the string "2024-11-22" to a datetime object



Explanation
strptime() parses a date string according to the specified format and creates a datetime object. <br><br> strptime() दिए गए format के अनुसार string को parse करके datetime object बनाता है।
Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad