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.

    [Reply]

  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

    [Reply]

  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!

    [Reply]

  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!

    [Reply]

  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!

    [Reply]

  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. ;-)

    [Reply]

  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!

    [Reply]

  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!

    [Reply]

  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

    [Reply]

  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 :)

    [Reply]

  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! :)

    [Reply]

  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 :).

    [Reply]

  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.

    [Reply]

  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

    [Reply]

  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.

    [Reply]

  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! :)

    [Reply]

  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 :)

    [Reply]

  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. :)

    [Reply]

  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. :)

    [Reply]

  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).

    [Reply]

Post a Comment

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

Powered by WP Hashcash