MulaiMulai sekarang secara gratis

Making relative datetimes

The Troubled Asset Relief Program (TARP) was passed in October of 2008 in an attempt to stablize the US financial system during the crisis of 2007-2008. To investigate the state of markets before and after the passage of TARP, you wish to create some datetimes for times before and after.

Latihan ini adalah bagian dari kursus

Intermediate Python for Finance

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

from datetime import datetime, timedelta

# TARP passed Oct 3 2008
tarp = datetime(2008, 10, 3)

# Seven days before TARP
week_before = tarp - timedelta(____ = 7)

# Print week_before
____
Edit dan Jalankan Kode