Lab 3

In this lab, I learned how to display the current date and time using python and displaying it neatly in the desired format.

Code

1 from datetime import datetime
2 now=datetime.now()
3 print now
4 print now.year
5 print now.month
6 print now.day
7 print str(now.month)+”/”+str(now.day)+”/”+str(now.year)
8 print str(now.hour)+”:”+str(now.minute)+”:”+ str(now.second)
9 print str(now.month)+”/”+str(now.day)+”/”+str(now.year) + ” ” + str(now.hour)+”:”+str(now.minute)+”:”+ str(now.second)

 

Lab 3 python

Leave a Reply

Your email address will not be published. Required fields are marked *