Generation

generate functionMon, 24 Apr 2023

Create a program which greets me every morning and calculates how many days I still have to live until I am at the average age of 85 years old. My birthday is on 10.1.1980.

def days_left(birthday): current_date = datetime.datetime.now() next_birthday_date = datetime.datetime(current_date.year, birthday.month, birthday.day) if next_birthday_date < current_date: next_birthday_date = datetime.datetime(current_date.year + 1, birthday.month, birthday.day) return (next_birthday_date - current_date).days def days_left_to_85(birthday): current_date = datetime.datetime.now() return (datetime.datetime(current_date.year + 85, birthday.month, birthday.day) - current_date).days def main(): birthday = datetime.datetime(1980, 1, 10) if days_left(birthday) == 1: print("Hey, it's your birthday today!") else: print("Hey, your birthday is in {} days!".format(days_left(birthday))) print

Want to kickstart your project?Use the new AI Studio to create your code