Решение на Астрологични забави от Димитрина Гецкова

Обратно към всички решения

Към профила на Димитрина Гецкова

Резултати

  • 10 точки от тестове
  • 1 отнета точка
  • 9 точки общо
  • 6 успешни тест(а)
  • 0 неуспешни тест(а)

Код

# task_1
def interpret_western_sign(day, month):
months = {1: [21, "capricorn", "aquarius"], 2: [19, "aquarius", "pisces"],
3: [21, "pisces", "aries"], 4: [21, "aries", "taurus"],
5: [21, "taurus", "gemini"], 6: [21, "gemini", "cancer"],
7: [23, "cancer", "leo"], 8: [23, "leo", "virgo"],
9: [23, "virgo", "libra"], 10: [23, "libra", "scorpio"],
11: [22, "scorpio", "sagittarius"],
12: [22, "sagittarius", "capricorn"]}
month_info = months.get(month)
# print (month_info)
if day < month_info[0]:
return month_info[1]
# print (month_info[1])
else:
return month_info[2]
# print (month_info[2])
# task_2
def interpret_chinese_sign(year):
months = 12
residue = year % months
years = {1: "rooster", 2: "dog", 3: "pig", 4: "rat", 5: "ox", 6: "tiger",
7: "rabbit", 8: "dragon", 9: "snake", 10: "horse", 11: "sheep",
0: "monkey"}
return years.get(residue)
# years = ["monkey", "rooster", "dog", "pig", "rat", "ox", "tiger",
# "rabbit", "dragon", "snake", "horse", "sheep"]
# return years[residue]
# task_3
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))

Лог от изпълнението

......
----------------------------------------------------------------------
Ran 6 tests in 0.006s

OK

История (2 версии и 0 коментара)

Димитрина обнови решението на 09.03.2015 23:58 (преди над 9 години)

+# task_1
+def interpret_western_sign (day, month):
+ months = {1:[21, "capricorn", "aquarius"], 2:[19, "aquarius", "pisces"],
+ 3:[21, "pisces", "aries"], 4:[21, "aries", "taurus"], 5:[21,"taurus", "gemini"],
+ 6:[21, "gemini", "cancer"], 7:[23, "cancer", "leo"], 8:[23, "leo", "virgo"],
+ 9:[23, "virgo", "libra"], 10:[23, "libra", "scorpio"], 11: [22, "scorpio", "sagittarius"],
+ 12:[22, "sagittarius", "capricorn"]}
+ month_info = months.get(month)
+ #print (month_info)
+ if day < month_info[0]:
+ #print (month_info[1])
+ return month_info[1]
+ else:
+ #print (month_info[2])
+ return month_info[2]
+
+# task_2
+def interpret_chinese_sign(year):
+ months = 12
+ residue = year % months
+ years_dic = {1:"rooster", 2:"dog", 3:"pig", 4:"rat", 5:"ox", 6:"tiger",
+ 7:"rabbit", 8:"dragon", 9:"snake", 10:"horse", 11:"sheep", 0:"monkey"} #important that 12%12=0 for december
+ return years_dic.get(residue)
+
+# task_3
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign (day, month), interpret_chinese_sign(year))
+

Димитрина обнови решението на 11.03.2015 15:39 (преди над 9 години)

# task_1
-def interpret_western_sign (day, month):
- months = {1:[21, "capricorn", "aquarius"], 2:[19, "aquarius", "pisces"],
- 3:[21, "pisces", "aries"], 4:[21, "aries", "taurus"], 5:[21,"taurus", "gemini"],
- 6:[21, "gemini", "cancer"], 7:[23, "cancer", "leo"], 8:[23, "leo", "virgo"],
- 9:[23, "virgo", "libra"], 10:[23, "libra", "scorpio"], 11: [22, "scorpio", "sagittarius"],
- 12:[22, "sagittarius", "capricorn"]}
+
+
+def interpret_western_sign(day, month):
+ months = {1: [21, "capricorn", "aquarius"], 2: [19, "aquarius", "pisces"],
+ 3: [21, "pisces", "aries"], 4: [21, "aries", "taurus"],
+ 5: [21, "taurus", "gemini"], 6: [21, "gemini", "cancer"],
+ 7: [23, "cancer", "leo"], 8: [23, "leo", "virgo"],
+ 9: [23, "virgo", "libra"], 10: [23, "libra", "scorpio"],
+ 11: [22, "scorpio", "sagittarius"],
+ 12: [22, "sagittarius", "capricorn"]}
month_info = months.get(month)
- #print (month_info)
+# print (month_info)
if day < month_info[0]:
- #print (month_info[1])
return month_info[1]
+# print (month_info[1])
else:
- #print (month_info[2])
return month_info[2]
+# print (month_info[2])
# task_2
+
+
def interpret_chinese_sign(year):
months = 12
residue = year % months
- years_dic = {1:"rooster", 2:"dog", 3:"pig", 4:"rat", 5:"ox", 6:"tiger",
- 7:"rabbit", 8:"dragon", 9:"snake", 10:"horse", 11:"sheep", 0:"monkey"} #important that 12%12=0 for december
- return years_dic.get(residue)
+ years = {1: "rooster", 2: "dog", 3: "pig", 4: "rat", 5: "ox", 6: "tiger",
+ 7: "rabbit", 8: "dragon", 9: "snake", 10: "horse", 11: "sheep",
+ 0: "monkey"}
+ return years.get(residue)
+# years = ["monkey", "rooster", "dog", "pig", "rat", "ox", "tiger",
+# "rabbit", "dragon", "snake", "horse", "sheep"]
+# return years[residue]
# task_3
+
+
def interpret_both_signs(day, month, year):
- return (interpret_western_sign (day, month), interpret_chinese_sign(year))
-
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))