0% found this document useful (0 votes)
4 views1 page

Date

Uploaded by

knadx619
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Date

Uploaded by

knadx619
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

On a new line, print now.year. Make sure you do it after setting the now variable!

Then, print out now.month.

Finally, print out now.day

code
from datetime import datetime
now = datetime.now()
print now
print now.year
print now.month
print now.day

Hot Date

Print the current date in the form of mm/dd/yyyy.

Change the string used above so that it uses a / character in between the %02d and
%04d placeholders instead of a - character.

code
rom datetime import datetime
now = datetime.now()
print '%02d/%02d/%04d' % (now.month, now.day, now.year)

1.
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 %02d placeholders.

Change the three things that you are printing from month, day, and year to
now.hour, now.minute, and now.second.

code
from datetime import datetime
now = datetime.now()

print '%02d-%02d-%04d', '%02d:%02d:%02d' % (now.month, now.day, now.year),


(now.hour,now.minute,now.second)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy