You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
3.8 KiB
105 lines
3.8 KiB
2 months ago
|
#! python
|
||
|
|
||
|
|
||
|
import datetime
|
||
|
import sys
|
||
|
|
||
|
today = datetime.date.today()
|
||
|
#birthday = datetime.date(1969,8,19)
|
||
|
birthday = datetime.datetime.strptime(sys.argv[1],'%d.%m.%Y').date()
|
||
|
|
||
|
#Konstanten
|
||
|
HAIR_GROWTH_PER_DAY = 0.4
|
||
|
NAIL_GROWTH_PER_DAY = 0.17
|
||
|
BREATHING_PER_DAY = 20000
|
||
|
HEART_RATE_PER_DAY = 100000
|
||
|
BLINKS_PER_DAY = 14400
|
||
|
URINE_PER_DAY = 1.5
|
||
|
DISTANCE_PER_DAY = 6
|
||
|
TAGNAMEN = ['Montag', 'Dienstag', ' Mittwoch', 'Donnerstag', 'Freitag', 'Samstag','Sonntag']
|
||
|
|
||
|
alterInTagen = (today - birthday).days
|
||
|
|
||
|
|
||
|
def wochentage(geburtsdatum):
|
||
|
wochentage_abgedeckt = set() # Ein Set, um die Wochentage zu verfolgen
|
||
|
jahr = geburtsdatum.year
|
||
|
alter = 0
|
||
|
|
||
|
while len(wochentage_abgedeckt) < 7: # Solange nicht alle 7 Wochentage abgedeckt sind
|
||
|
aktueller_geburtstag = geburtsdatum.replace(year=jahr)
|
||
|
wochentag = aktueller_geburtstag.weekday() # 0=Montag, ..., 6=Sonntag
|
||
|
wochentage_abgedeckt.add(wochentag) # Füge den Wochentag hinzu
|
||
|
jahr += 1
|
||
|
alter += 1
|
||
|
|
||
|
return alter
|
||
|
|
||
|
def sternzeichen(geburtsdatum):
|
||
|
tag = geburtsdatum.day
|
||
|
monat = geburtsdatum.month
|
||
|
|
||
|
if (monat == 3 and tag >= 21) or (monat == 4 and tag <= 19):
|
||
|
return "Widder"
|
||
|
elif (monat == 4 and tag >= 20) or (monat == 5 and tag <= 20):
|
||
|
return "Stier"
|
||
|
elif (monat == 5 and tag >= 21) or (monat == 6 and tag <= 20):
|
||
|
return "Zwillinge"
|
||
|
elif (monat == 6 and tag >= 21) or (monat == 7 and tag <= 22):
|
||
|
return "Krebs"
|
||
|
elif (monat == 7 and tag >= 23) or (monat == 8 and tag <= 22):
|
||
|
return "Löwe"
|
||
|
elif (monat == 8 and tag >= 23) or (monat == 9 and tag <= 22):
|
||
|
return "Jungfrau"
|
||
|
elif (monat == 9 and tag >= 23) or (monat == 10 and tag <= 22):
|
||
|
return "Waage"
|
||
|
elif (monat == 10 and tag >= 23) or (monat == 11 and tag <= 21):
|
||
|
return "Skorpion"
|
||
|
elif (monat == 11 and tag >= 22) or (monat == 12 and tag <= 21):
|
||
|
return "Schütze"
|
||
|
elif (monat == 12 and tag >= 22) or (monat == 1 and tag <= 19):
|
||
|
return "Steinbock"
|
||
|
elif (monat == 1 and tag >= 20) or (monat == 2 and tag <= 18):
|
||
|
return "Wassermann"
|
||
|
elif (monat == 2 and tag >= 19) or (monat == 3 and tag <= 20):
|
||
|
return "Fische"
|
||
|
|
||
|
def format_number(num, num_type = 'dec', sep = '.'):
|
||
|
# num_type = 'dec'
|
||
|
num_string = str(num)
|
||
|
prefix = ''
|
||
|
dist = 3
|
||
|
num_formated = ''
|
||
|
|
||
|
# Format Hexadezimal
|
||
|
if num_type == 'hex':
|
||
|
num_string = hex(num)[2:]
|
||
|
prefix = '0x'
|
||
|
dist = 2
|
||
|
# Format Binär
|
||
|
elif num_type == 'bin':
|
||
|
num_string = bin(num)[2:]
|
||
|
prefix = '0b'
|
||
|
dist = 4
|
||
|
|
||
|
# Trennzeichen einfügen
|
||
|
for i, l in enumerate(num_string[::-1]):
|
||
|
if i > 0 and i%dist == 0:
|
||
|
num_formated += sep
|
||
|
num_formated += l
|
||
|
|
||
|
# formatierten String in korrekter Reihenfolge zurückgeben
|
||
|
return prefix + num_formated[::-1]
|
||
|
|
||
|
print(f'Dein Geburstag war ein {TAGNAMEN[birthday.weekday()]}')
|
||
|
print(f'Dein Sternzeichen ist {sternzeichen(birthday)}.')
|
||
|
print(f'Du bist heute {alterInTagen} Tage alt.')
|
||
|
print(f'Hättet du dir niemals die Haare geschnitten, wären sie jetzt {alterInTagen * HAIR_GROWTH_PER_DAY/100} cm lang')
|
||
|
print(f'Hättet du dir niemals die Fingernägel geschnitten, wären sie jetzt {alterInTagen * NAIL_GROWTH_PER_DAY/100} cm lang')
|
||
|
print(f'Im Schnitt hat dein Herz seit deiner Geburt {format_number(alterInTagen * HEART_RATE_PER_DAY)} mal geschlagen')
|
||
|
print(f'Im Schnitt hast du {format_number(alterInTagen * BREATHING_PER_DAY)} Atemzüge gemacht.')
|
||
|
print(f'Während du wach bist hast du bislang {format_number(alterInTagen * BLINKS_PER_DAY)} Lidschläge mit den Augen gemacht.')
|
||
|
print(f'Deine Nieren haben bislang etwa {(URINE_PER_DAY * alterInTagen)} Liter Urin produziert.')
|
||
|
print(f'zu Fuss hast du ca. eine Strecke von {format_number(alterInTagen * DISTANCE_PER_DAY)}km zurückgelegt.')
|
||
|
print(f'An deinem {wochentage(birthday)}. Geburtstag hast du an jedem Wochentag einmal Geburtag gehabt.')
|