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

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

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

Резултати

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

Код

HOROSCOPE_WEST = ["aries",
"taurus",
"gemini",
"cancer",
"leo",
"virgo",
"libra",
"scorpio",
"sagittarius",
"capricorn",
"aquarius",
"pisces"]
HOROSCOPE_EAST = ["monkey",
"rooster",
"dog",
"pig",
"rat",
"ox",
"tiger",
"rabbit",
"dragon",
"snake",
"horse",
"sheep"]
def interpret_western_sign(day, month):
if (day > 20 and month == 3) or (day < 21 and month == 4):
return HOROSCOPE_WEST[0]
elif (day > 20 and month == 4) or (day < 21 and month == 5):
return HOROSCOPE_WEST[1]
elif (day > 20 and month == 5) or (day < 21 and month == 6):
return HOROSCOPE_WEST[2]
elif (day > 20 and month == 6) or (day < 22 and month == 7):
return HOROSCOPE_WEST[3]
elif (day > 21 and month == 7) or (day < 23 and month == 8):
return HOROSCOPE_WEST[4]
elif (day > 22 and month == 8) or (day < 23 and month == 9):
return HOROSCOPE_WEST[5]
elif (day > 22 and month == 9) or (day < 23 and month == 10):
return HOROSCOPE_WEST[6]
elif (day > 22 and month == 10) or (day < 22 and month == 11):
return HOROSCOPE_WEST[7]
elif (day > 21 and month == 11) or (day < 22 and month == 12):
return HOROSCOPE_WEST[8]
elif (day > 21 and month == 12) or (day < 20 and month == 1):
return HOROSCOPE_WEST[9]
elif (day > 19 and month == 1) or (day < 19 and month == 2):
return HOROSCOPE_WEST[10]
else:
return HOROSCOPE_WEST[11]
def interpret_chinese_sign(year):
if (year >= 0):
sign = year % 12
return HOROSCOPE_EAST[sign]
else:
sign = (-year) % 12
return HOROSCOPE_EAST[12 - sign]
def interpret_both_signs(day, month, year):
west = interpret_western_sign(day, month)
east = interpret_chinese_sign(year)
return tuple([west, east])

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

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

OK

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

Иван обнови решението на 10.03.2015 22:54 (преди над 9 години)

+horoscopeWest = ["aries", "taurus", "gemini", "cancer", "leo","virgo", "libra", "scorpio", "sagittarius", "capricorn", "aquarius", "pisces"]
+
+horoscopeEast = ["monkey", "rooster", "dog", "pig", "rat", "ox",
+ "tiger", "rabbit", "dragon", "snake", "horse", "sheep"]
+
+
+
+def interpret_western_sign (day, month):
+ if (day>20 and month==3) or (day<21 and month==4):
+ return horoscopeWest[0]
+ elif (day>20 and month==4) or (day<21 and month==5):
+ return horoscopeWest[1]
+ elif (day>20 and month==5) or (day<21 and month==6):
+ return horoscopeWest[2]
+ elif (day>20 and month==6) or (day<22 and month==7):
+ return horoscopeWest[3]
+ elif (day>21 and month==7) or (day<23 and month==8):
+ return horoscopeWest[4]
+ elif (day>22 and month==8) or (day<23 and month==9):
+ return horoscopeWest[5]
+ elif (day>22 and month==9) or (day<23 and month==10):
+ return horoscopeWest[6]
+ elif (day>22 and month==10) or (day<22 and month==11):
+ return horoscopeWest[7]
+ elif (day>21 and month==11) or (day<22 and month==12):
+ return horoscopeWest[8]
+ elif (day>21 and month==12) or (day<20 and month==1):
+ return horoscopeWest[9]
+ elif (day>19 and month==1) or (day<19 and month==2):
+ return horoscopeWest[10]
+ else:
+ return horoscopeWest[11]
+
+def interpret_chinese_sign(year):
+ if (year >= 0):
+ sign = year%12
+ return horoscopeEast[sign]
+ else:
+ sign = (-year)%12
+ return horoscopeEast[12 - sign]
+def interpret_both_signs(day, month, year):
+ west = interpret_western_sign(day, month)
+ east = interpret_chinese_sign(year)
+ signs = [west, east]
+ return tuple(signs)
+
+
+
+
  • Имената на променливите в Python са в snake_case
  • Между функциите оставяме 2 празни реда
  • Имената на константите са в SCREAMING_SNAKE_CASE
  • Трябва да оставяш интервали около операторите
  • Прочети pep8 или поне пусни проверка на решението си
  • Как можеш да обединиш ред 44 и 45? Нямаше ли литерал за създаване на tuple-и?

Иван обнови решението на 11.03.2015 11:30 (преди над 9 години)

-horoscopeWest = ["aries", "taurus", "gemini", "cancer", "leo","virgo", "libra", "scorpio", "sagittarius", "capricorn", "aquarius", "pisces"]
+horoscopeWest = ["aries",
+ "taurus",
+ "gemini",
+ "cancer",
+ "leo",
+ "virgo",
+ "libra",
+ "scorpio",
+ "sagittarius",
+ "capricorn",
+ "aquarius",
+ "pisces"]
-horoscopeEast = ["monkey", "rooster", "dog", "pig", "rat", "ox",
- "tiger", "rabbit", "dragon", "snake", "horse", "sheep"]
+horoscopeEast = ["monkey",
+ "rooster",
+ "dog",
+ "pig",
+ "rat",
+ "ox",
+ "tiger",
+ "rabbit",
+ "dragon",
+ "snake",
+ "horse",
+ "sheep"]
-
-def interpret_western_sign (day, month):
- if (day>20 and month==3) or (day<21 and month==4):
+def interpret_western_sign(day, month):
+ if (day > 20 and month == 3) or (day < 21 and month == 4):
return horoscopeWest[0]
- elif (day>20 and month==4) or (day<21 and month==5):
+ elif (day > 20 and month == 4) or (day < 21 and month == 5):
return horoscopeWest[1]
- elif (day>20 and month==5) or (day<21 and month==6):
+ elif (day > 20 and month == 5) or (day < 21 and month == 6):
return horoscopeWest[2]
- elif (day>20 and month==6) or (day<22 and month==7):
+ elif (day > 20 and month == 6) or (day < 22 and month == 7):
return horoscopeWest[3]
- elif (day>21 and month==7) or (day<23 and month==8):
+ elif (day > 21 and month == 7) or (day < 23 and month == 8):
return horoscopeWest[4]
- elif (day>22 and month==8) or (day<23 and month==9):
+ elif (day > 22 and month == 8) or (day < 23 and month == 9):
return horoscopeWest[5]
- elif (day>22 and month==9) or (day<23 and month==10):
+ elif (day > 22 and month == 9) or (day < 23 and month == 10):
return horoscopeWest[6]
- elif (day>22 and month==10) or (day<22 and month==11):
+ elif (day > 22 and month == 10) or (day < 22 and month == 11):
return horoscopeWest[7]
- elif (day>21 and month==11) or (day<22 and month==12):
+ elif (day > 21 and month == 11) or (day < 22 and month == 12):
return horoscopeWest[8]
- elif (day>21 and month==12) or (day<20 and month==1):
+ elif (day > 21 and month == 12) or (day < 20 and month == 1):
return horoscopeWest[9]
- elif (day>19 and month==1) or (day<19 and month==2):
+ elif (day > 19 and month == 1) or (day < 19 and month == 2):
return horoscopeWest[10]
else:
return horoscopeWest[11]
+
def interpret_chinese_sign(year):
if (year >= 0):
- sign = year%12
+ sign = year % 12
return horoscopeEast[sign]
else:
- sign = (-year)%12
+ sign = (-year) % 12
return horoscopeEast[12 - sign]
+
+
def interpret_both_signs(day, month, year):
west = interpret_western_sign(day, month)
east = interpret_chinese_sign(year)
- signs = [west, east]
- return tuple(signs)
+ return tuple([west, east])
-
-
-
-

Иван обнови решението на 11.03.2015 11:33 (преди над 9 години)

-horoscopeWest = ["aries",
+HOROSCOPE_WEST = ["aries",
"taurus",
"gemini",
"cancer",
"leo",
"virgo",
"libra",
"scorpio",
"sagittarius",
"capricorn",
"aquarius",
"pisces"]
-horoscopeEast = ["monkey",
+HOROSCOPE_EAST = ["monkey",
"rooster",
"dog",
"pig",
"rat",
"ox",
"tiger",
"rabbit",
"dragon",
"snake",
"horse",
"sheep"]
def interpret_western_sign(day, month):
if (day > 20 and month == 3) or (day < 21 and month == 4):
- return horoscopeWest[0]
+ return HOROSCOPE_WEST[0]
elif (day > 20 and month == 4) or (day < 21 and month == 5):
- return horoscopeWest[1]
+ return HOROSCOPE_WEST[1]
elif (day > 20 and month == 5) or (day < 21 and month == 6):
- return horoscopeWest[2]
+ return HOROSCOPE_WEST[2]
elif (day > 20 and month == 6) or (day < 22 and month == 7):
- return horoscopeWest[3]
+ return HOROSCOPE_WEST[3]
elif (day > 21 and month == 7) or (day < 23 and month == 8):
- return horoscopeWest[4]
+ return HOROSCOPE_WEST[4]
elif (day > 22 and month == 8) or (day < 23 and month == 9):
- return horoscopeWest[5]
+ return HOROSCOPE_WEST[5]
elif (day > 22 and month == 9) or (day < 23 and month == 10):
- return horoscopeWest[6]
+ return HOROSCOPE_WEST[6]
elif (day > 22 and month == 10) or (day < 22 and month == 11):
- return horoscopeWest[7]
+ return HOROSCOPE_WEST[7]
elif (day > 21 and month == 11) or (day < 22 and month == 12):
- return horoscopeWest[8]
+ return HOROSCOPE_WEST[8]
elif (day > 21 and month == 12) or (day < 20 and month == 1):
- return horoscopeWest[9]
+ return HOROSCOPE_WEST[9]
elif (day > 19 and month == 1) or (day < 19 and month == 2):
- return horoscopeWest[10]
+ return HOROSCOPE_WEST[10]
else:
- return horoscopeWest[11]
+ return HOROSCOPE_WEST[11]
def interpret_chinese_sign(year):
if (year >= 0):
sign = year % 12
- return horoscopeEast[sign]
+ return HOROSCOPE_EAST[sign]
else:
sign = (-year) % 12
- return horoscopeEast[12 - sign]
+ return HOROSCOPE_EAST[12 - sign]
def interpret_both_signs(day, month, year):
west = interpret_western_sign(day, month)
east = interpret_chinese_sign(year)
return tuple([west, east])