DEV Community 👩‍💻👨‍💻


Posted on

[Basic] Python age calculator

🙋‍♂️ Hey there!
I hope you are doing well.

Here, I'm sharing the knowledge I gained from creating basic python projects for beginners.

After all

"The best way to learn things is getting hands dirty!"

Show me the code: python basic project with source code

1) What I Built

Python age calculator

  • Reusable Choices loop
  • Simple Age input with format validation (dd-mm-yyyy)
  • Age calculation logic to calculate age in various units
  • Print Age Calculation data

2) How I Built

  • Whole calculation logic is separate from UX
  • Code split is managed through a reusable manner
    • Common Logic is separate from app-specific logic
    • Logic is written in separate reusable function chunks

As per I believe, this blog post is helpful to those who are looking for python project ideas for beginners.

Top comments (3)

geraldew profile image

It took me quite a lot of clicks to find the place where the calculations happen. From a quick look you don't seem to have a valid calculation method.

In short, the line:

  • years = seconds // (3600 * 24 * 365)

will not always be correct (for a couple of reasons).

iamjaydev profile image
iamjaydev Author

@geraldew Thanks for feedback 👍

harshad_tweet profile image
Harshad Prajapati

I'm trying to implement something like this and I've found this one!

Thanks for sharing

🌚 Browsing with dark mode makes you a better developer by a factor of exactly 40.

It's a scientific fact.