Complete the code to import the module needed for date and time handling.
import [1]
The datetime module is used to work with dates and times in Python.
Complete the code to get the current date and time.
now = datetime.[1]()date() which returns only the date.time() which is not a class method here.The datetime.datetime() class method now() returns the current local date and time.
Fix the error in the code to format the current date as 'YYYY-MM-DD'.
formatted_date = now.[1]("%Y-%m-%d")
strptime() which parses strings to datetime.to_string().The strftime() method formats a datetime object into a string according to the given format.
Fill both blanks to create a timedelta of 5 days and add it to the current date.
future_date = now + datetime.[1](days=[2])
date instead of timedelta.The timedelta class represents a duration, and you can add it to a datetime object to get a future date.
Fill both blanks to create a dictionary with keys as month names and values as the number of days, only for months with more than 30 days.
months = {"January": 31, "February": 28, "April": 30, "May": 31}
long_months = {k: v for k, v in months.items() if v {BLANK_2}} {{BLANK_2}}This dictionary comprehension keeps months where the number of days is greater than 30, using ':' to separate keys and values.