LAB 3

Description:

 This lab is about printing out the day and time in the correct order. In order to do this we must first import the datetime. Then we set the variable for the date (month, day, year) and the time (hour, minute, second). Finally we print it out in one line with a space in between.

Code:

from datetime import datetime
now = datetime.now ()
current_year = now.year
current_month = now.month
current_day = now.day
print (current_month)
print (current_day)
print (current_year)

print str(now.month) + “/” + str(now.day) + “/” + str(now.year)

current_hour = now.hour
current_minute = now.minute
current_second = now.second
print (current_hour)
print (current_minute)
print (current_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:

farhin

This is the code

 

farhin2

    This is the output

Leave a Reply

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