Skip to content

Instantly share code, notes, and snippets.

@lamegaton
Created September 14, 2018 08:02
Show Gist options
  • Save lamegaton/733d97f3d0abd84e7bcb3eed64bf3be7 to your computer and use it in GitHub Desktop.
Save lamegaton/733d97f3d0abd84e7bcb3eed64bf3be7 to your computer and use it in GitHub Desktop.
Calculate and print out time left on earth
import time
from datetime import date
#def count_time_left():
today =date.today()
while True:
yourMonth = int(input("Enter your Month of birth MM: "))
if yourMonth >12 or yourMonth < 0:
print('please try MM again!')
continue
else:
while True:
yourDay = int(input("Enter your Day of birth DD: "))
if (yourMonth == 2 and yourDay >28) or yourDay > 31 or yourDay <0:
print('please try DD again!')
continue
else:
while True:
yourYear = int(input("Enter your Year of birth YYYY: "))
if yourYear > int(today.year):
print('please try YYYY again!')
continue
else:
break
break
break
yourBD = date(yourYear, yourMonth, yourDay)
today =date.today()
isoToday = date.isoformat(today)
print("Today is: ",isoToday)
print("If you live 60 years or {} days of your lifespan".format(60*365))
dayLeft = date(yourYear + 60, yourMonth, yourDay) - today
dayLeft = int(dayLeft.days)
print("The days you have left on earth is:", dayLeft,"days")
print("You have lived",21900 - dayLeft,"days")
def print_table(data, cols, wide):
'''Prints formatted data on columns of given width.'''
n, r = divmod(len(data), cols)
pat = '{{:{}}}'.format(wide)
line = '\n'.join(pat * cols for _ in range(n))
last_line = pat * r
print(line.format(*data))
print(last_line.format(*data[n*cols:]))
data1 = ["X" for i in range(int(round((21900 - dayLeft)/10)))]
data = ["." for i in range(int(dayLeft/10))]
data1.extend(data)
print_table(data1,73,1)
print('Momento Mori, mate!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment