Lab Description:
In this lab, I generated the datetime on Python. From Python, I imported the current time and date of the day. I learn to combine strings and how to include one string or variable into the results. In this lab, I learn to assemble the time and date in the form of mm/dd/yyyy and in the form of hh:mm:ss for time. And finally in the end, I included both mm/dd/yyyy hh:mm:ss with the spacing inbetween.
Code:
from datetime import datetime
now = datetime.now()
print (now)
print (now.month)
print (now.day)
print (now.year)
print (str(now.month) + “/” + str(now.day) + “/” + str(now.year))
print (now.hour)
print (now.minute)
print (now.second)
print (str(now.hour) + “:” + str(now.minute) + “:” + str(now.second))
print (str(now.month) + “/” + str(now.day) + “/” + str(now.year) + ” ” + str(now.hour) + “:” + str(now.minute) + “:” + str(now.second))
ScreenShots: