Pythondex

Quiz

Python Datetime Module Quiz

Which function returns the current date and time in Python?

datetime.date.today()
datetime.datetime.now()
datetime.time.now()
datetime.current()

What does datetime.date.today() return?

Current time only
Current date only
Both date and time
Unix timestamp

What will this code print?

5
2000
15
Error

What does datetime.timedelta(days=7) do?

Subtracts 7 days from today
Adds 7 days to today
Returns current time
Formats the date

What does strftime('%d-%m-%Y') do?

Returns date as a string in day-month-year format
Returns current timestamp
Adds days to the date
Calculates difference between dates

What does datetime.datetime.now().time() return?

Current date
Current date and time
Current time only
Unix timestamp