Importing from a module
Another useful module is datetime
, which allows you to create and work with dates and times, as well as time zones and time periods!
The datetime
module has a function called date
.
In this exercise, you'll practice importing and using the date
method from the datetime
module and use it to create a variable.
This exercise is part of the course
Intermediate Python for Developers
Exercise instructions
- Import the
date
function from thedatetime
module. - Create a variable called
deadline
, assigning a call ofdate()
, passing in the numbers2024
,1
, and19
, in that order, separated by commas. - Check the data type of
deadline
. - Print the
deadline
variable.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import date from the datetime module
____ ____ ____ ____
# Create a variable called deadline
deadline = ____(____, ____, ____)
# Check the data type
print(____(____))
# Print the deadline
print(____)