1 2 3 4 5 6 7 8 9 10 11 12 | 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 |
-
Mobile
Subscribe
Archives
Web sites
Pages
Meta

{ 20 } Comments
Happy Birthday man.
Dream on:P
Happy b’day
Congratulations!
Merry Christmas *g*
Ohw, sorry, I mean:
Happy Birthday! May all your wishes come true!
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!
Also, happy birthday.
Happy Birthday!
Happy Birthday!
Happy Birthday man…
Too funny. lol
Hehe, happy birthday, Aaron
@Sandy- Good call! Fixed!
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
.
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.
I’ve probably thought about this too much… but your statement doesn’t work if
month > birthday month
and
day
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.
Happy birthday!! You know birthdays are good for you, because the more you have, the longer you live!
happy birthday. My son wishes you a happy birthday as well
Thank you everyone! It was a good birthday. I still maintain, however, that I’m still 29.
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.
Congratulations!
I also suggest dropping the bad habit of using bitwise operators (&) instead of boolean ones (and).
Post a Comment