NEW
Font size
WorksheetsDatetime_builtinfunctions_pythonquiz
Total questions: 10
Worksheet time: 5mins
What does datetime.datetime.now() return?
Current date and time
Current date only
Current time only
None of the above
Which function gives the day of the month from a datetime object?
.day
.month
.date
.now
import datetime
print(datetime.datetime.now().strftime("%B"))
what will be the output of the following?
Current month in full name (e.g., January)
Current year
Current month in number format
Gives error
What does the strftime method do?
Converts date to a string in a specified format
Extracts the current time
Formats strings only
none of these
from datetime import date
today = date.today()
print(today.strftime("%Y-%m-%d"))
What is the output of this code?
Current date in "YYYY-MM-DD" format
Current time
Error
None of the above
What does random.randint(1, 10) do?
Returns a random number between 1 and 10 (inclusive)
Always returns 10
Returns a random number between 1 and 9 (inclusive)
None of these
Which function generates a random number in the range [0, n)?
random.randrange(n)
random.randint(0, n)
random.random()
random()
import random
print(random.choice("Kidzian"))
What does this code do?
Selects a random letter from "Kidzian"
Shuffles the string
Prints the string "Kidzian"
None of these
# What will be the output of the following code?
import datetime
today = datetime.datetime.now()
print(today.strftime("%A"))
Current weekday as a number
Current weekday as a full name
Current month
Error
In which of these years will February have 29 days?
1900
2000
2023
2025
