Date and Time

This Weeks’ Classwork is another tutorial within code academy. The lesson (called Date and Time) is used to help teach the many ways python can use strings. This time, lesson is make the current date and time appear within the code.

The First step, as shown below instructs the user(in this case myself) to create a new variable called “now” and within this variable create a function called “datetime.now”. After that print the variable now. This allows python to display the current time of when the code began to run.date2

After that, instead of making python show the time. I have made python show the current date. Since at the moment we do not need the date code, it was promptly deleted and replace with new code (now.year, now.month, now.day)

date3

While still using the “now.year, now.month, now.day” code; the new instructions is print the date by using the %/ operator. This acts as a placeholder for the % command and will use what is within the parenthesis.

date4

Now the next task is instead of showing the date, the time must be shown. Same Process, but replacing “now.year, now.month, now.day” with  “now.hour, now.minute, now.second”

date5

and lastly, it is time to display both “now.year, now.month, now.day” and “now.hour, now.minute, now.second”

date6