1. Complete read_date(): • Read an input string representing a date in the format yyyy-mm-dd. • Create a date object from the input string. o Retun the date object. 2. Call read_date) to read four (unique) date objects and store the date objects in a list. 3. Call sorted() to sort the list of date objects, earliest first. Store the sorted dates in a new list. 4. Output the sorted_dates, in the format mm/dd/yy. • Hint: Use strftime) to format the date outputs. (See resource below.) 5. Output the number of days between the last two dates in the sorted list as a positive number. 6. Output the date that is 3 weeks from the most recent date in the format "July 4, 1776'. o Hint: Use timedelta() to set a duration of time for the arithmetic on date objects. (See resources below.) Ex: timedelta(days=50, seconds=27, hours=B, weeks=2) will define a duration of 50 days + 27 seconds +8 hours + 2 weeks. 7. Output the full name of the day of the week of the earliest day.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%
Complete the code to implement the following operations:
1. Complete read_date():
• Read an input string representing a date in the format yyyy-mm-dd.
o Create a date object from the input string.
• Return the date object.
2. Call read_date() to read four (unique) date objects and store the date objects in a list.
3. Call sorted() to sort the list of date objects, earliest first. Store the sorted dates in a new list.
4. Output the sorted_dates, in the format mm/dd/yy.
• Hint: Use strftime() to format the date outputs. (See resource below.)
5. Output the number of days between the last two dates in the sorted list as a positive number.
6. Output the date that is 3 weeks from the most recent date in the format "July 4, 1776'.
• Hint: Use timedelta() to set a duration of time for the arithmetic on date objects. (See resources below.)
Ex: timedelta(days=50, seconds=27, hours=B, weeks=2) will define a duration of 50 days + 27 seconds + 8
+2
<s.
7. Output the full name of the day of the week of the earliest day.
Ex: If the input is:
2022-01-27
2022-07-04
2020-12-31
2022-07-29
the output is:
12/31/2020
01/27/2022
07/04/2022
07/29/2022
25
August 19, 2022
Thursday
Transcribed Image Text:Complete the code to implement the following operations: 1. Complete read_date(): • Read an input string representing a date in the format yyyy-mm-dd. o Create a date object from the input string. • Return the date object. 2. Call read_date() to read four (unique) date objects and store the date objects in a list. 3. Call sorted() to sort the list of date objects, earliest first. Store the sorted dates in a new list. 4. Output the sorted_dates, in the format mm/dd/yy. • Hint: Use strftime() to format the date outputs. (See resource below.) 5. Output the number of days between the last two dates in the sorted list as a positive number. 6. Output the date that is 3 weeks from the most recent date in the format "July 4, 1776'. • Hint: Use timedelta() to set a duration of time for the arithmetic on date objects. (See resources below.) Ex: timedelta(days=50, seconds=27, hours=B, weeks=2) will define a duration of 50 days + 27 seconds + 8 +2 <s. 7. Output the full name of the day of the week of the earliest day. Ex: If the input is: 2022-01-27 2022-07-04 2020-12-31 2022-07-29 the output is: 12/31/2020 01/27/2022 07/04/2022 07/29/2022 25 August 19, 2022 Thursday
main.py
Load default template.
1 from datetime import date, timedelta, time
2
3 # 1 Complete read_date()
4 def read_date():
"""'Read a string representing a date in the format 2121-04-12, create a
date object from the input string, and return the date object
II IIII
9 # 2. Use read_date() to read four (unique) date objects, putting the date objects in a list
10
11 # 3. Use sorted() to sort the dotes, earliest first
12
13 # 4. Output the sorted_dates in order, earliest first, in the format mn/dd/yy
14
15 # 5. Output the number of days between the last two dates in the sorted list
16 #
as a positive number
17
18 # 6. Output the date that is 3 weeks from the most recent date in the list
19
20 # 7. Output the full name of the day of the week of the earliest day
21
Transcribed Image Text:main.py Load default template. 1 from datetime import date, timedelta, time 2 3 # 1 Complete read_date() 4 def read_date(): """'Read a string representing a date in the format 2121-04-12, create a date object from the input string, and return the date object II IIII 9 # 2. Use read_date() to read four (unique) date objects, putting the date objects in a list 10 11 # 3. Use sorted() to sort the dotes, earliest first 12 13 # 4. Output the sorted_dates in order, earliest first, in the format mn/dd/yy 14 15 # 5. Output the number of days between the last two dates in the sorted list 16 # as a positive number 17 18 # 6. Output the date that is 3 weeks from the most recent date in the list 19 20 # 7. Output the full name of the day of the week of the earliest day 21
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY