Решение на Астрологични забави от Ивелина Ватева

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

Към профила на Ивелина Ватева

Резултати

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

Код

#solution.py
# The first part of the task.
# Function that takes a day and a month and give you the Western_Sign
def interpret_western_sign(day, month):
western_sing = ""
if(month == 3 and day >= 21) or (month == 4 and day <= 20):
western_sing = "aries"
elif(month == 4 and day >= 21) or (month == 5 and day <= 20):
western_sing = "taurus"
elif(month == 5 and day >= 21) or (month == 6 and day <= 20):
western_sing = "gemini"
elif(month == 6 and day >= 21) or (month == 7 and day <= 22):
western_sing = "cancer"
elif(month == 7 and day >= 23) or (month == 8 and day <= 22):
western_sing = "leo"
elif(month == 8 and day >= 23) or (month == 9 and day <= 22):
western_sing = "virgo"
elif(month == 9 and day >= 23) or (month == 10 and day <= 22):
western_sing = "libra"
elif(month == 10 and day >= 23) or (month == 11 and day <= 21):
western_sing = "scorpio"
elif(month == 11 and day >= 22) or (month == 12 and day <= 21):
western_sing = "sagittarius"
elif(month == 12 and day >= 22) or (month == 1 and day <= 20):
western_sing = "capricorn"
elif(month == 1 and day >= 21) or (month == 2 and day <= 18):
western_sing = "aquarius"
else:
western_sing = "pisces"
return western_sing;
#print(interpret_western_sign(26,9))
# The 2nd part of the task
# Function that needs a year and gives you the "Chinese_Sign"
def interpret_chinese_sign(year):
chinese_sign = ""
sing_list = ["monkey", "rooster", "dog", "pig", "rat", "ox", "tiger", "rabbit", "dragon", "snake", "horse", "sheep"]
a = year % 12
chinese_sign = sing_list[a]
return chinese_sign;
#print(interpret_chinese_sign(1986))
# The 3rd part of the task
# Function that needs a day, a month and an year and gives you "tuple" with 2 string: Western_Sign and Chinese_Sign
#def interpret_both_signs(day, month, year)
def interpret_both_signs(day, month, year):
western_sing = interpret_western_sign(day,month)
chinese_sign = interpret_chinese_sign(year)
return(western_sing, chinese_sign)
#print(interpret_both_signs(4,12,1986))

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

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

OK

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

Ивелина обнови решението на 10.03.2015 14:05 (преди над 9 години)

+#Task 1
+
+# The first part of the task.
+# Function that takes a day and a month and give you the Western_Sign
+
+def interpret_western_sign(day, month):
+ western_sing = ""
+ if(month == 3 and day >= 21) or (month == 4 and day <= 20):
+ western_sing = "aries"
+ elif(month == 4 and day >= 21) or (month == 5 and day <= 20):
+ western_sing = "taurus"
+ elif(month == 5 and day >= 21) or (month == 6 and day <= 20):
+ western_sing = "gemini"
+ elif(month == 6 and day >= 21) or (month == 7 and day <= 22):
+ western_sing = "cancer"
+ elif(month == 7 and day >= 23) or (month == 8 and day <= 22):
+ western_sing = "leo"
+ elif(month == 8 and day >= 23) or (month == 9 and day <= 22):
+ western_sing = "virgo"
+ elif(month == 9 and day >= 23) or (month == 10 and day <= 22):
+ western_sing = "libra"
+ elif(month == 10 and day >= 23) or (month == 11 and day <= 21):
+ western_sing = "scorpio"
+ elif(month == 11 and day >= 22) or (month == 12 and day <= 21):
+ western_sing = "sagittarius"
+ elif(month == 12 and day >= 22) or (month == 1 and day <= 20):
+ western_sing = "capricorn"
+ elif(month == 1 and day >= 21) or (month == 2 and day <= 18):
+ western_sing = "aquarius"
+ else:
+ western_sing = "pisces"
+
+ return western_sing;
+
+#print(interpret_western_sign(26,9))
+
+
+# The 2nd part of the task
+# Function that needs a year and gives you the "Chinese_Sign"
+def interpret_chinese_sign(year):
+ chinese_sign = ""
+
+ if year % 12 == 0:
+ chinese_sign = "monkey"
+ elif year % 12 == 1:
+ chinese_sign = "rooster"
+ elif year % 12 == 2:
+ chinese_sign = "dog"
+ elif year % 12 == 3:
+ chinese_sign = "pig"
+ elif year % 12 == 4:
+ chinese_sign = "rat"
+ elif year % 12 == 5:
+ chinese_sign = "ox"
+ elif year % 12 == 6:
+ chinese_sign = "tiger"
+ elif year % 12 == 7:
+ chinese_sign = "rabbit"
+ elif year % 12 == 8:
+ chinese_sign = "dragon"
+ elif year % 12 == 9:
+ chinese_sign = "snake"
+ elif year % 12 == 10:
+ chinese_sign = "horse"
+ else:
+ chinese_sign = "sheep"
+
+ return chinese_sign;
+
+#print(interpret_chinese_sign(1986))
+
+
+# The 3rd part of the task
+# Function that needs a day, a month and an year and gives you "tuple" with 2 string: Western_Sign and Chinese_Sign
+#def interpret_both_signs(day, month, year)
+
+def interpret_both_signs(day, month, year):
+ western_sing = interpret_western_sign(day,month)
+ chinese_sign = interpret_chinese_sign(year)
+
+ return(western_sing, chinese_sign)
+
+#print(interpret_both_signs(4,12,1986))

Ивелина обнови решението на 11.03.2015 00:04 (преди над 9 години)

-#Task 1
+#solution.py
# The first part of the task.
# Function that takes a day and a month and give you the Western_Sign
def interpret_western_sign(day, month):
western_sing = ""
if(month == 3 and day >= 21) or (month == 4 and day <= 20):
western_sing = "aries"
elif(month == 4 and day >= 21) or (month == 5 and day <= 20):
western_sing = "taurus"
elif(month == 5 and day >= 21) or (month == 6 and day <= 20):
western_sing = "gemini"
elif(month == 6 and day >= 21) or (month == 7 and day <= 22):
western_sing = "cancer"
elif(month == 7 and day >= 23) or (month == 8 and day <= 22):
western_sing = "leo"
elif(month == 8 and day >= 23) or (month == 9 and day <= 22):
western_sing = "virgo"
elif(month == 9 and day >= 23) or (month == 10 and day <= 22):
western_sing = "libra"
elif(month == 10 and day >= 23) or (month == 11 and day <= 21):
western_sing = "scorpio"
elif(month == 11 and day >= 22) or (month == 12 and day <= 21):
western_sing = "sagittarius"
elif(month == 12 and day >= 22) or (month == 1 and day <= 20):
western_sing = "capricorn"
elif(month == 1 and day >= 21) or (month == 2 and day <= 18):
western_sing = "aquarius"
else:
western_sing = "pisces"
return western_sing;
#print(interpret_western_sign(26,9))
# The 2nd part of the task
# Function that needs a year and gives you the "Chinese_Sign"
def interpret_chinese_sign(year):
chinese_sign = ""
-
- if year % 12 == 0:
- chinese_sign = "monkey"
- elif year % 12 == 1:
- chinese_sign = "rooster"
- elif year % 12 == 2:
- chinese_sign = "dog"
- elif year % 12 == 3:
- chinese_sign = "pig"
- elif year % 12 == 4:
- chinese_sign = "rat"
- elif year % 12 == 5:
- chinese_sign = "ox"
- elif year % 12 == 6:
- chinese_sign = "tiger"
- elif year % 12 == 7:
- chinese_sign = "rabbit"
- elif year % 12 == 8:
- chinese_sign = "dragon"
- elif year % 12 == 9:
- chinese_sign = "snake"
- elif year % 12 == 10:
- chinese_sign = "horse"
- else:
- chinese_sign = "sheep"
-
+ sing_list = ["monkey", "rooster", "dog", "pig", "rat", "ox", "tiger", "rabbit", "dragon", "snake", "horse", "sheep"]
+ a = year % 12
+ chinese_sign = sing_list[a]
return chinese_sign;
#print(interpret_chinese_sign(1986))
# The 3rd part of the task
# Function that needs a day, a month and an year and gives you "tuple" with 2 string: Western_Sign and Chinese_Sign
#def interpret_both_signs(day, month, year)
def interpret_both_signs(day, month, year):
western_sing = interpret_western_sign(day,month)
chinese_sign = interpret_chinese_sign(year)
return(western_sing, chinese_sign)
#print(interpret_both_signs(4,12,1986))