DEV Community

Cover image for Cool Python Project 1: Birthday Estimator
Abhi Develops - SunTech
Abhi Develops - SunTech

Posted on

3 2

Cool Python Project 1: Birthday Estimator

Hi Everyone! Welcome to Cool Python Projects!
In this post I will be showing you how to make a Birthday Estimator in Python. Please remember to follow me to stay updated on any new projects.

Python Code:

import datetime

def get_birthday_from_user():

   year = int(input('What year were you born? '))

   month = int(input('What month were you born? '))

   day = int(input('What day were you born? '))

   user_bday=datetime.date(year,month,day)

   return user_bday

def compute_days_between_dates(bday2,today2):

   bday2 = datetime.date(today2.year,bday2.month, bday2.day)

   days3 = bday2 - today2

   print(days3, type(days3))

   return days3.days

def print_birthday_information(bday4):

   if bday4 < 0:

       print('Your Birthday was {0} days ago!'.format(-bday4))

def main ():

   user_bday2 = get_birthday_from_user()

   today = datetime.date.today()

   days_to_bday = compute_days_between_dates(user_bday2,today)

   print_birthday_information(days_to_bday)

main()
Enter fullscreen mode Exit fullscreen mode

I hope you enjoyed this Python project.

All the projects code in the series

AWS Q Developer image

Your AI Code Assistant

Ask anything about your entire project, code and get answers and even architecture diagrams. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Start free in your IDE

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →