Skip to content

Instantly share code, notes, and snippets.

@horstjens
Created December 13, 2020 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save horstjens/851b400f0de1cefb3bb4aed2736107b8 to your computer and use it in GitHub Desktop.
Save horstjens/851b400f0de1cefb3bb4aed2736107b8 to your computer and use it in GitHub Desktop.
Dennis Horst Python
# ---- edit by Horst a lot ---
def weeks_left_calc(year_born=None, current_year=2020 ):
'''
Returns years, weeks, days or None,None,None:
If input is correct, returns:
years: the number of years you have to live to 90 years old in digits.
weeks: the number of weeks you have to live to 90 years old in digits.
days: the number of days you have to live to 90 years old in digits.
If input is not correct, returns:
None, None, None
Parameters:
year_born (int): A decimal integer
current_year: An integer
'''
if year_born is None:
year_born = input("Enter the year you were born: ")
try:
year_born =int(year_born)
except ValueError:
print("enter only integer for year")
return None, None, None
# --- edit by Horst ---
years_left = year_born + 90 - current_year
weeks_left = years_left * 52
days_left = years_left * 365
#print(weeks_left_calc)
#print (f"F string {weeks_left_calc}")
print (f"Here are your absolute years left to 90: {years_left}")
print (f"Here are your absolute weeks left to 90: {weeks_left}")
print (f"Here are your absolute days left to 90: {days_left}")
#return(weeks_left_calc)
# -------- edit by Horst ------------
return years_left, weeks_left, days_left
if __name__ == "__main__":
# bmi_calc(1.7,90)
print("i call the function")
years, weeks, days = weeks_left_calc()
print(f"the function gives back: {years} years, {weeks} weeks, {days} days.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment