Aliases, multi-imports, and the `np.` you'll see everywhere — step 9 of 9
One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.
Last one. Cursor wrote a one-page script that's supposed to print today's
year using datetime, but the imports are wrong. Three things to fix:
- The first line uses
import datetime as dtbut then later callsdatetime.now()directly — those don't match. - The second line
from datetime import *is the antipattern. Replace it with a targetedfrom datetime import datetime. - After fixing the first two, the third line works on its own — but
remove the redundant first line entirely. You only need one of the two
ways to reach
datetime.now().
After the fix, the script should print the current year (a 4-digit number).
We'll grade by checking the output is 2026 (matches the current year).
One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.
Last one. Cursor wrote a one-page script that's supposed to print today's
year using datetime, but the imports are wrong. Three things to fix:
- The first line uses
import datetime as dtbut then later callsdatetime.now()directly — those don't match. - The second line
from datetime import *is the antipattern. Replace it with a targetedfrom datetime import datetime. - After fixing the first two, the third line works on its own — but
remove the redundant first line entirely. You only need one of the two
ways to reach
datetime.now().
After the fix, the script should print the current year (a 4-digit number).
We'll grade by checking the output is 2026 (matches the current year).
this step needs the editor
on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.