File: lifespan.py

package info (click to toggle)
egenix-mx-base 3.2.8-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,420 kB
  • ctags: 6,208
  • sloc: ansic: 22,304; python: 18,124; sh: 137; makefile: 121
file content (21 lines) | stat: -rw-r--r-- 557 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
""" Calculate some informations about lifespans.
"""
from mx.DateTime import *
import sys

# Get data from user
print 'Please enter your birthday (year,month,day), e.g. 1969,12,1:'
try:
    year,month,day = input('>>> ')
except:
    print '* Sorry, wrong entry.'
    sys.exit()
print

# Output the lifespan in different formats
birthday = Date(year,month,day)
lifespan = now() - birthday
print 'Lifespan:'
print ' =',lifespan.days,'days'
print ' =',int(lifespan / (29.53 * oneDay)),'moons (+/- 1)'
print ' =',lifespan / (365.2422 * oneDay),'tropical years'