LAB:3

Date and time:

using  strings and console input in python I learn how to display the current date and time. In order for me to be able to do it, I had to use the function called  ”datetime.now()” using that function I was able to retrieve the month,the day,and the year.also I had to use the string concatenation to print out the current time.

Code:

from datetime import datetime
now = datetime.now()
print(now)
current_year = now.year
print(now.year)
print(now.day)
print(now.month)
print (str(now.year)+"/"+str(now.month)+"/"+str(now.day))+ " " + str (now.hour)+":"+str(now.minute)+ ":"+ str (now.second)

Screenshots:

:date and time

 

Leave a Reply

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