

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: Welcome to Pandas
incomplete
2: Data Types
incomplete
3: Data Analytics Workflow
incomplete
4: Dates and Times
incomplete
5: Datetime Math
incomplete
6: Comparing Dates
incomplete
7: List Comprehensions
incomplete
8: Dictionary Comprehensions
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Sometimes you don't need to do date math; you just need to know which date comes first. Questions like:
Luckily, compatible datetime values support normal comparison operators
You can compare two datetime values with operators like <, >, <=, and >=:
returned_at = datetime(2026, 5, 15)
due_date = datetime(2026, 6, 1)
if returned_at < due_date:
print("Book returned on time")
Which comes in handy whenever you want to filter a dataset by date.
You can also sort datetime values directly:
dates = [datetime(2026, 3, 1), datetime(2026, 1, 1), datetime(2026, 2, 1)]
dates.sort()
print(dates)
# [datetime.datetime(2026, 1, 1, 0, 0), datetime.datetime(2026, 2, 1, 0, 0), datetime.datetime(2026, 3, 1, 0, 0)]
SnackStack's ops team needs to know which appliances are overdue for a firmware update. Policy says a device must be updated within a certain number of minutes after its firmware was installed.
Complete the needs_firmware_update function. It accepts:
installed_at: when the device's current firmware was installedrequired_after_mins: the number of minutes after installation that an update becomes requiredchecked_at: the time of the compliance check