Dhanu P.

asked • 11/30/22

11.12 LAB: Dates

Complete the code to implement the following operations:

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


Michael M.

I don't think this is the correct forum for this type of question; if you want to go through this code and talk through how to do this, I would highly suggest getting a tutor who can walk you through it. This section is more for asking specific questions - not posting an entire lab for solutions.
Report

11/30/22

Dhanu P.

Thank You!
Report

12/01/22

1 Expert Answer

By:

Arwin A. answered • 01/14/23

Tutor
New to Wyzant

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.