That Blue Square Thing

Python Programming - How old are you - in days?

One little Python project that caught my eye was one to calculate how old a person is. Of course, you can do this approximately if you have their age or year of birth, but there are better ways as well...

A helpful thing to double check your answers is an online calculator to do the same thingexternal link icon.

Here's one solution that calculates and prints a persons age based on an inputted date of birth. It uses a set of library functions to handle the date/time aspects. These need importing first. This is a fairly standard sort of thing to need to do - I've done it in Java and VB for example. Once you have the standard libraries on board life becomes a lot easier.

Here's a screenshot of the code I used (which may well not be the best or most efficient code in the world by the way! I'm learning Python too...) and a text file which can be copied into IDLE if necessary.

Screenshot of python code for days old program

PDF iconProgram file: days old - copy the code into IDLE

I'm sure the program can be developed and improved. There may well be better was to use the libraries for example.