Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Date and time values with the datetime module worksheet is part of the VCE Software Development - U4O1 - development and evaluation journey. Print it as a booklet?
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1now = datetime.now() | AThe brackets are missing, so the function is never called and the current time is not stored. It should be datetime.now(). | |
| 2now.strftime("%d/%m/%Y") | BGets the current date and time and stores it in the variable now | |
| 3Import the datetime class from the datetime module so you can use it in your program | Cfrom datetime import datetime | |
| 4Subtract an earlier date from a later date to find the duration between them | DFormats the date as text in day/month/year form, such as 25/03/2026 | |
| 5now = datetime.now | Egap = end - start | |
| 6now.strftime(%H:%M) | FThe format code is not in quotes. It should be now.strftime("%H:%M") because strftime needs a string. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
from datetime import datetime — Brings in the datetime tool so Python can get the current date and time with datetime.now(), format it with strftime, and subtract two dates to find a duration.from datetime import datetimenow = datetime.now()print(now.strftime("%d/%m/%Y"))start = datetime.now()
duration = datetime.now() - startprint(now.strftime("%Y"))