MCPcopy Create free account
hub / github.com/LinkedInLearning/learning-python-2896241 / main

Function main

Ch4 - Dates and Times/dates_finished.py:11–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9from datetime import datetime
10
11def main():
12 ## DATE OBJECTS
13 # Get today's date from the simple today() method from the date class
14 today = date.today()
15 print ("Today's date is ", today)
16
17 # print out the date's individual components
18 print ("Date Components: ", today.day, today.month, today.year)
19
20 # retrieve today's weekday (0=Monday, 6=Sunday)
21 print ("Today's Weekday #: ", today.weekday())
22 days = ["monday","tuesday","wednesday","thursday","friday","saturday","sunday"]
23 print ("Which is a " + days[today.weekday()])
24
25 ## DATETIME OBJECTS
26 # Get today's date from the datetime class
27 today = datetime.now()
28 print ("The current date and time is ", today)
29
30 # Get the current time
31 t = datetime.time(datetime.now())
32 print ("The current time is ", t)
33
34
35if __name__ == "__main__":

Callers 1

dates_finished.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected