Иван обнови решението на 10.03.2015 22:43 (преди над 9 години)
+def interpret_western_sign(day, month):
+ DAYS_IN_MONTH={1:0,2:31,3:59,4:90,5:120,6:151,7:181,
+ 8:212,9:243,10:273,11:304,12:335}
+ ZODIAC_DAY=DAYS_IN_MONTH[month]+day
+ if ZODIAC_DAY<=20:
+ return 'capricorn'
+ elif ZODIAC_DAY<=50:
+ return 'aquarius'
+ elif ZODIAC_DAY<=79:
+ return 'pisces'
+ elif ZODIAC_DAY<=110:
+ return 'aries'
+ elif ZODIAC_DAY<=140:
+ return 'taurus'
+ elif ZODIAC_DAY<=171:
+ return 'gemini'
+ elif ZODIAC_DAY<=203:
+ return 'cancer'
+ elif ZODIAC_DAY<=234:
+ return 'leo'
+ elif ZODIAC_DAY<=265:
+ return 'virgo'
+ elif ZODIAC_DAY<=295:
+ return 'libra'
+ elif ZODIAC_DAY<=325:
+ return 'scorpio'
+ elif ZODIAC_DAY<=356:
+ return 'sagittarius'
+ elif ZODIAC_DAY<=365:
+ return 'capricorn'
+ else:
+ return 'SYSTEM SELF DESTRUCT';
+
+def interpret_chinese_sign(year):
+ CHINESE_ZODIAC={0:'monkey',1:'rooster',2:'dog',
+ 3:'pig',4:'rat',5:'ox',
+ 6:'tiger',7:'rabbit',8:'dragon',
+ 9:'snake',10:'horse',11:'sheep'}
+ return CHINESE_ZODIAC[year%12]
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day,month),interpret_chinese_sign(year))
+
- Има начин да намалиш броя на
if
-овете - Пусни pep8 проверка - липсват интервали около операторите, по 2 празни реда между функциите...