Q:

Write a NumPy program to get the dates of yesterday, today and tomorrow

0

Write a NumPy program to get the dates of yesterday, today and tomorrow.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
yesterday = np.datetime64('today', 'D') - np.timedelta64(1, 'D')
print("Yestraday: ",yesterday)
today     = np.datetime64('today', 'D')
print("Today: ",today)
tomorrow  = np.datetime64('today', 'D') + np.timedelta64(1, 'D')
print("Tomorrow: ",tomorrow)

Sample Output:

Yestraday:  2017-03-24                                                 
Today:  2017-03-25                                                     
Tomorrow:  2017-03-26

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now