Python Forum
Age calculation - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Age calculation (/thread-22216.html)



Age calculation - Kaanatmaca - Nov-04-2019

Hi,how can we calculate someones age by using python coding? (In the calculation not only the diffrence between years are needed,the months and days should be used too.)

Can someone help me,

Thank You
Kaan


RE: Age calculation - buran - Nov-04-2019

We are glad to help, but we are not going to do your [home]work for you.
Post your code in python tags, full traceback (if any) - in error tags and ask specific question)s).
For start you may write down how would you solve the problem without computer/script - i.e. step by step, then code each step


RE: Age calculation - Kaanatmaca - Nov-04-2019

This is not my homework.Im just trying to learn to do it because I know that oneday I will need to do this


RE: Age calculation - buran - Nov-04-2019

homework or not - my advise still stands. You need to show effort to solving the problem


RE: Age calculation - DeaD_EyE - Nov-04-2019

https://docs.python.org/3/library/datetime.html
https://www.guru99.com/date-time-and-datetime-classes-in-python.html
  • Create a date object (birthday)
  • Create a date object (today)
  • Calculate the timedelta (today - birthday), then you get the days