Python’s datetime module is essential for working with dates, times, and timestamps. Whether you’re logging events or scheduling tasks, this quiz helps test your understanding of date and time manipulation in Python.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Which module in Python is used to handle date and time?
Correct
Incorrect
Question 2 of 15
2. Question
What does datetime.now() return?
Correct
Incorrect
Question 3 of 15
3. Question
What is the output of datetime.today().date()?
Correct
Incorrect
Question 4 of 15
4. Question
Which class provides both date and time in the datetime module?
Correct
Incorrect
Question 5 of 15
5. Question
What does timedelta(days=5) represent?
Correct
Incorrect
Question 6 of 15
6. Question
How do you format a date to string in Python?
Correct
Incorrect
Question 7 of 15
7. Question
What is the output of:
from datetime import datetime print(datetime(2023, 1, 1).strftime(‘%Y’))
Correct
Incorrect
Question 8 of 15
8. Question
Which directive returns the full weekday name using `strftime()`?
Correct
Incorrect
Question 9 of 15
9. Question
Which method is used to parse a string into a `datetime` object?
Correct
Incorrect
Question 10 of 15
10. Question
What is the output of:
from datetime import date print(date.today().year)
Correct
Incorrect
Question 11 of 15
11. Question
Which of the following gives you just the current time?
Correct
Incorrect
Question 12 of 15
12. Question
What will this return?
from datetime import timedelta print(timedelta(days=1, hours=5))
Correct
Incorrect
Question 13 of 15
13. Question
Which of the following is a valid date object?
Correct
Incorrect
Question 14 of 15
14. Question
What is the default time if only `date` is used?
Correct
Incorrect
Question 15 of 15
15. Question
What is the output of:
from datetime import timedelta print(timedelta(weeks=2).days)
Correct
Incorrect
Summary
This quiz covered the essential concepts of Python date and time, including formatting, parsing, current timestamps, timedelta operations, and string conversions. Mastering the `datetime` module is vital for any time-sensitive application, from logging to automation.
At QuizOrbit, our team specializes in fun, informative quizzes across topics like general knowledge, technology, and entertainment. Boost your knowledge with our expert-designed quizzes.