#1 The date time library
instructions:
Click Save & Submit Code to continue.
#2 Getting the Current Date And Time
instructions:
- Create a variable called
now
and store the result ofdatetime.now()
in it. - Then,
print
the value ofnow
.
#3 Extracting information
Instructions :
- On a new line,
print now.year
. Make sure you do it after setting thenow
variable! - Then,
print
outnow.month
. - Finally,
print
outnow.day
Print the current date in the form ofmm/dd/yyyy
.
- Change the string so that it uses a
/
character in between the%s
placeholders instead of a-
character. - Re-arrange the parameters to the right of the
%
operator so that you printnow.month
, thennow.day
, thennow.year
.
Similar to the last exercise, print the current time in the pretty form of hh:mm:ss
.
- Change the string that you are printing so that you have a
:
character in between the%s
placeholders. - Change the three things that you are printing from month, day, and year to
now.hour
,now.minute
, andnow.second
.#6 Grand Finale
instructions :
Print the date and time together in the form:mm/dd/yyyy hh:mm:ss
.To start, change the format string to the left of the
%
operator.- Ensure that it has 6
%s
placeholders. - Put slashes and colons and a space between the placeholders so that they fit the format above.
Then, change the variables in the parentheses to the right of the
%
operator. - Place the variables so that
now.month, now.day, now.year
are beforenow.hour, now.minute, now.second
. Make sure that there is a(
before the six and a)
after them.
- Ensure that it has 6
EXPERIENCE :
in this assignment I was actually feeling very comfortable since it was not as hard as the previous ones. I felt like we just had substitute some things for the others for examples commas or slash or colon sign. it was time taking at first but going through hints I was able to complete the assignment pretty quickly.