Явор обнови решението на 10.03.2015 22:03 (преди над 9 години)
+def interpret_western_sign(day, month):
+ if day >= 21 and month == 3 or day <= 20 and month == 4:
+ return "aries"
+ elif day >= 21 and month == 4 or day <= 20 and month == 5:
+ return "taurus"
+ elif day >= 21 and month == 5 or day <= 20 and month == 6:
+ return "gemini"
+ elif day >= 21 and month == 6 or day <= 22 and month == 7:
+ return "cancer"
+ elif day >= 23 and month == 7 or day <= 22 and month == 8:
+ return "leo"
+ elif day >= 23 and month == 8 or day <= 22 and month == 9:
+ return "virgo"
+ elif day >= 23 and month == 9 or day <= 22 and month == 10:
+ return "libra"
+ elif day >= 23 and month == 10 or day <= 21 and month == 11:
+ return "scorpio"
+ elif day >= 22 and month == 11 or day <= 21 and month == 12:
+ return "sagittarius"
+ elif day >= 22 and month == 12 or day <= 20 and month == 1:
+ return "capricorn"
+ elif day >= 21 and month == 1 or day <= 18 and month == 2:
+ return "aquarius"
+ else:
+ return "pisces"
+
+def interpret_chinese_sign(year):
+ signs = (
+ "monkey", "rooster", "dog", "pig",
+ "rat", "ox", "tiger", "rabbit",
+ "dragon", "snake", "horse", "sheep"
+ )
+ return signs[year%12]
+
+def interpret_both_signs(day, month, year):
+ result = (interpret_western_sign(day, month), interpret_chinese_sign(year))
+ return result
- Прекалил си малко с
if
-овете в първата функция. Имаш късмет, че са само 12 зодии, ами ако са 112? - Не спазваш pep8 - брой празни редове, интервали около операторите...