Skip to content

29 And Holding

from datetime import date
 
birth_day = date(1977, 6, 9)
right_now = date.today()
 
if (right_now.month >= birth_day.month) & (right_now.day >= birth_day.day):
    age = right_now.year - birth_day.year
else:
    age = right_now.year - birth_day.year - 1
 
if age >= 30:
    age = 29

{ 20 } Comments

  1. Christer Edwards using Mozilla Firefox Mozilla Firefox 2.0.0.4 on Ubuntu Linux Ubuntu Linux | June 9, 2007 at 7:23 am | Permalink

    Happy Birthday man.

  2. Tiago Boldt Sousa using Mozilla Firefox Mozilla Firefox 2.0.0.4 on Ubuntu Linux Ubuntu Linux | June 9, 2007 at 7:31 am | Permalink

    Dream on:P

    Happy b’day

  3. GooZ using Mozilla Firefox Mozilla Firefox 2.0.0.4 on Ubuntu Linux Ubuntu Linux | June 9, 2007 at 7:43 am | Permalink

    Congratulations!

  4. Kim using Mozilla Firefox Mozilla Firefox 2.0.0.4 on Ubuntu Linux Ubuntu Linux | June 9, 2007 at 7:46 am | Permalink

    Merry Christmas *g*

    Ohw, sorry, I mean:

    Happy Birthday! May all your wishes come true!

  5. Sandy using Mozilla Firefox Mozilla Firefox 2.0.0.4 on Ubuntu Linux Ubuntu Linux | June 9, 2007 at 8:03 am | Permalink

    It’s a good thing you didn’t try to use this script before this year…your age would have been off for the first half of every year!

  6. Sandy using Mozilla Firefox Mozilla Firefox 2.0.0.4 on Ubuntu Linux Ubuntu Linux | June 9, 2007 at 8:03 am | Permalink

    Also, happy birthday. ;-)

  7. RainCT using Mozilla Firefox Mozilla Firefox 2.0.0.3 on Ubuntu Linux Ubuntu Linux | June 9, 2007 at 8:22 am | Permalink

    Happy Birthday!

  8. Greg G using Mozilla Firefox Mozilla Firefox 2.0.0.4 on Ubuntu Linux Ubuntu Linux | June 9, 2007 at 8:46 am | Permalink

    Happy Birthday!

  9. Chris Rohde using Mozilla Firefox Mozilla Firefox 2.0.0.4 on Ubuntu Linux Ubuntu Linux | June 9, 2007 at 9:26 am | Permalink

    Happy Birthday man…

    Too funny. lol

  10. Lasse Havelund using Mozilla Firefox Mozilla Firefox 2.0.0.4 on Ubuntu Linux Ubuntu Linux | June 9, 2007 at 9:29 am | Permalink

    Hehe, happy birthday, Aaron :)

  11. Aaron using Mozilla Firefox Mozilla Firefox 2.0.0.4 on Ubuntu Linux Ubuntu Linux | June 9, 2007 at 9:43 am | Permalink

    @Sandy- Good call! Fixed! :)

  12. Jonathan Vasquez using Mozilla Firefox Mozilla Firefox 2.0.0.4 on Ubuntu Linux Ubuntu Linux | June 9, 2007 at 11:44 am | Permalink

    Happy Birthday. Now if I can just make believe this is C++ and make it a little more realistic :).

    from datetime import date

    birth_day = date(1977, 6, 9)
    right_now = date.today()

    if (right_now.month >= birth_day.month) & (right_now.day >= birth_day.day):
    age = right_now.year - birth_day.year

    age = 30;

    enjoy :).

  13. Iain Nicol using Epiphany Epiphany 2.18 on Ubuntu Linux Ubuntu Linux | June 9, 2007 at 11:49 am | Permalink

    Happy birthday. If you don’t like if statements–or like the elegance of modular arithmetic–there’s always:

    age = age % 30

    Ah, to be zero again.

  14. Iain Nicol using Epiphany Epiphany 2.18 on Ubuntu Linux Ubuntu Linux | June 9, 2007 at 3:44 pm | Permalink

    I’ve probably thought about this too much… but your statement doesn’t work if

    month > birthday month
    and
    day

  15. Iain Nicol using Epiphany Epiphany 2.18 on Ubuntu Linux Ubuntu Linux | June 9, 2007 at 3:46 pm | Permalink

    Oops, I’m wasn’t escaping quoting XHTML characters.

    It doesn’t work if today’s month is more than the birth month, but today’s day is less than the birth day.

  16. Amy Rose using Konqueror Konqueror 3.5 on Kubuntu Linux Kubuntu Linux | June 9, 2007 at 4:59 pm | Permalink

    Happy birthday!! You know birthdays are good for you, because the more you have, the longer you live! :)

  17. Hunding using Mozilla Firefox Mozilla Firefox 2.0.0.4 on Ubuntu Linux Ubuntu Linux | June 9, 2007 at 6:21 pm | Permalink

    happy birthday. My son wishes you a happy birthday as well :)

  18. Aaron using Mozilla Firefox Mozilla Firefox 2.0.0.4 on Ubuntu Linux Ubuntu Linux | June 10, 2007 at 6:12 am | Permalink

    Thank you everyone! It was a good birthday. I still maintain, however, that I’m still 29. :)

  19. Chip Bennett using Mozilla Firefox Mozilla Firefox 2.0.0.3 on Windows Windows XP | June 10, 2007 at 8:05 am | Permalink

    Happy Birthday! Coincidentally, we share the same birthdate. Of course, my script must be different from yours, because I don’t have any problems claiming that I’m now 30. :)

  20. Marius Gedminas using Mozilla Firefox Mozilla Firefox 2.0.0.4 on Ubuntu Linux Ubuntu Linux | June 10, 2007 at 9:37 am | Permalink

    Congratulations!

    I also suggest dropping the bad habit of using bitwise operators (&) instead of boolean ones (and).

Post a Comment

Your email is never published nor shared. Required fields are marked *

Powered by WP Hashcash