1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

人生の日付をPythonが教えてくれたのだ。

Posted at

はじめに

人生は有限なので、己が有意義に思うことで生きましょう。
皆そう言いますよね。

というわけで

  • 何日生きたのか?
  • あと何日生きるのか?
    のスクリプトを書きました。
    簡単です。

スクリプト

your_lifetime.py
# coding:utf-8

import datetime

birthday = datetime.date(1992, 2, 5) #自分の生年月日。お好みで変更下さい。
today = datetime.date.today()
finalday = datetime.date(2092, 2, 5) #人生百年の時代ですからね。
elapsed0 = finalday - today
elapsed1 = today - birthday
days0 = elapsed0.days
days1 = elapsed1.days
print("{0} 日で天に召されますよ".format(days0))
print("あなたは {0} 日生きましたよ".format(days1))

結果

/usr/bin/python /Users/Desktop/your_lifetime.py
26779 日で天に召されますよ
あなたは 9746 日生きましたよ

Process finished with exit code 0

結論

簡単ですが、考えさせられることが多いスクリプト。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?