Никола обнови решението на 11.03.2015 00:25 (преди над 9 години)
+import datetime
+from intervaltree import Interval, IntervalTree
+signs = IntervalTree()
+
+signs[80:110] = "aries"
+signs[111:140] = "taurus"
+signs[141:171] = "gemini"
+signs[172:203] = "cancer"
+signs[204:234] = "leo"
+signs[235:265] = "virgo"
+signs[266:295] = "libra"
+signs[296:325] = "scorpio"
+signs[326:355] = "sagittarius"
+signs[0:20] = "capricorn"
+signs[21:50] = "aquarius"
+signs[51:79] = "pisces"
+
+# task1
+def interpret_western_sign(day, month):
+ year_day = datetime.date(2015, month, day).timetuple().tm_yday
+ if year_day == 356:
+ year_day = 0
+ return sorted(signs[year_day])[0].data
+
+chinese_signs = [
+ "rat",
+ "ox",
+ "tiger",
+ "rabbit",
+ "dragon",
+ "snake",
+ "horse",
+ "sheep",
+ "monkey",
+ "rooster",
+ "dog",
+ "pig"
+]
+
+# task 2
+def interpret_chinese_sign(year):
+ index = (year - 1900) % 12
+ return chinese_signs[index]
+
+# task 3
+def interpret_both_signs(day, month, year):
+ western = interpret_western_sign(day, month)
+ chin = interpret_chinese_sign(year)
+ return (western, chin)
В домашните си не може да ползвате външни библиотеки.