Антонио обнови решението на 11.03.2015 09:34 (преди над 9 години)
+def interpret_western_sign (day, month) :
+ signs = [(21, "capricorn"), (20, "aquarius"), (21, "pisces")
+ (21, "aries"), (21, "taurus"), (21, "gemini")
+ (23, "cancer"), (23, "leo"), (23, "virgo")
+ (23, "libra"), (22, "scorpio"), (22, "sagittarius")]
+ if month > 0 and month <= 12 and day > 0 :
+ if month < 8 and month % 2 is not 0 and day > 31 :
+ return
+ if month >= 8 and month % 2 is 0 and day > 31 :
+ return
+ if month < 8 and month % 2 is 0 and day > 30 and month is not 2 :
+ return
+ if month > 8 and month % 2 is not 0 and day > 30 :
+ return
+ if month is 2 :
+ return
+ else :
+ if day < signs[month-1] [0] :
+ return signs[month-1] [1]
+ else :
+ return signs[month] [1]
+ else:
+ return
+def interpret_chinese_sign (year) :
+ chinese_signs = ["rat", "ox", "tiger", "rabbit"
+ "dragon", "snake", "horse", "sheep"
+ "monkey", "rooster", "dog", "pig"]
+ index = year % 1900 % 12
+ return chinese_signs [index]
+
+def interpret_both_signs (day, month, year) :
+ western_sign = interpret_western_sign(day, month)
+ chinese_sign = interpret_chinese_sign(year)
+ return (western_sign, chinese_sign)
Ако беше пуснал примерните тестове, щеше да ти се наложи да помедитираш над следния проблем:
TypeError: 'tuple' object is not callable