Date and Time

Date and Time(1) Date and Time(2) Date and Time(3) Date and Time(4)Date and Time(5) Date and Time(6) Lab Description:

In this lab, we learn how to input the current date and time into Python using a code called from datetime import datetime. In order for me to have Python show the current time, I type now = datetime.now() and on the bottom, I type print now and the codes will run with the result of the date and the time. On the same page with the previous codes I put, I type print now.year, now.month and now.day to get separate answers for the day (4/3/2016 would turn into 2016, 4 and 3). To have Python have slashes between the month, day and year, I insert %s/ three times, looks like this (%s/%s/%s/) and next to it, I put (now.month, now.day, now.year). The code would look like this, print ‘%s/%s/%s/ %  (now.month, now.day, now.year) and the result comes out as 4/3/2016. For the time, I do the same thing except instead of slashes I put colons (%s:%s:%s: %) and I would get 17:21:46. Then at the end, I simply put all those codes together and print the result and I get 4/3/2016 17:23:32. Upon completing this lab, I learned how to make the date and time on Python and I had fun. It was simple and easy to do.