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

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

Към профила на Иван Тодоров

Резултати

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

Код

def interpret_western_sign(day, month):
DAYS_IN_MONTH = {1: 0, 2: 31, 3: 59, 4: 90, 5: 120, 6: 151, 7: 181,
8: 212, 9: 243, 10: 273, 11: 304, 12: 335}
ZODIAC_DAY = DAYS_IN_MONTH[month] + day
if ZODIAC_DAY <= 20:
return 'capricorn'
elif ZODIAC_DAY <= 50:
return 'aquarius'
elif ZODIAC_DAY <= 79:
return 'pisces'
elif ZODIAC_DAY <= 110:
return 'aries'
elif ZODIAC_DAY <= 140:
return 'taurus'
elif ZODIAC_DAY <= 171:
return 'gemini'
elif ZODIAC_DAY <= 203:
return 'cancer'
elif ZODIAC_DAY <= 234:
return 'leo'
elif ZODIAC_DAY <= 265:
return 'virgo'
elif ZODIAC_DAY <= 295:
return 'libra'
elif ZODIAC_DAY <= 325:
return 'scorpio'
elif ZODIAC_DAY <= 356:
return 'sagittarius'
else:
return 'capricorn'
def interpret_chinese_sign(year):
CHINESE_ZODIAC = {0: 'monkey', 1: 'rooster', 2: 'dog',
3: 'pig', 4: 'rat', 5: 'ox',
6: 'tiger', 7: 'rabbit', 8: 'dragon',
9: 'snake', 10: 'horse', 11: 'sheep'}
return CHINESE_ZODIAC[year % 12]
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 версии и 1 коментар)

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

+def interpret_western_sign(day, month):
+ DAYS_IN_MONTH={1:0,2:31,3:59,4:90,5:120,6:151,7:181,
+ 8:212,9:243,10:273,11:304,12:335}
+ ZODIAC_DAY=DAYS_IN_MONTH[month]+day
+ if ZODIAC_DAY<=20:
+ return 'capricorn'
+ elif ZODIAC_DAY<=50:
+ return 'aquarius'
+ elif ZODIAC_DAY<=79:
+ return 'pisces'
+ elif ZODIAC_DAY<=110:
+ return 'aries'
+ elif ZODIAC_DAY<=140:
+ return 'taurus'
+ elif ZODIAC_DAY<=171:
+ return 'gemini'
+ elif ZODIAC_DAY<=203:
+ return 'cancer'
+ elif ZODIAC_DAY<=234:
+ return 'leo'
+ elif ZODIAC_DAY<=265:
+ return 'virgo'
+ elif ZODIAC_DAY<=295:
+ return 'libra'
+ elif ZODIAC_DAY<=325:
+ return 'scorpio'
+ elif ZODIAC_DAY<=356:
+ return 'sagittarius'
+ elif ZODIAC_DAY<=365:
+ return 'capricorn'
+ else:
+ return 'SYSTEM SELF DESTRUCT';
+
+def interpret_chinese_sign(year):
+ CHINESE_ZODIAC={0:'monkey',1:'rooster',2:'dog',
+ 3:'pig',4:'rat',5:'ox',
+ 6:'tiger',7:'rabbit',8:'dragon',
+ 9:'snake',10:'horse',11:'sheep'}
+ return CHINESE_ZODIAC[year%12]
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day,month),interpret_chinese_sign(year))
+

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

def interpret_western_sign(day, month):
- DAYS_IN_MONTH={1:0,2:31,3:59,4:90,5:120,6:151,7:181,
- 8:212,9:243,10:273,11:304,12:335}
- ZODIAC_DAY=DAYS_IN_MONTH[month]+day
- if ZODIAC_DAY<=20:
+ DAYS_IN_MONTH = {1: 0, 2: 31, 3: 59, 4: 90, 5: 120, 6: 151, 7: 181,
+ 8: 212, 9: 243, 10: 273, 11: 304, 12: 335}
+ ZODIAC_DAY = DAYS_IN_MONTH[month] + day
+ if ZODIAC_DAY <= 20:
return 'capricorn'
- elif ZODIAC_DAY<=50:
+ elif ZODIAC_DAY <= 50:
return 'aquarius'
- elif ZODIAC_DAY<=79:
+ elif ZODIAC_DAY <= 79:
return 'pisces'
- elif ZODIAC_DAY<=110:
+ elif ZODIAC_DAY <= 110:
return 'aries'
- elif ZODIAC_DAY<=140:
+ elif ZODIAC_DAY <= 140:
return 'taurus'
- elif ZODIAC_DAY<=171:
+ elif ZODIAC_DAY <= 171:
return 'gemini'
- elif ZODIAC_DAY<=203:
+ elif ZODIAC_DAY <= 203:
return 'cancer'
- elif ZODIAC_DAY<=234:
+ elif ZODIAC_DAY <= 234:
return 'leo'
- elif ZODIAC_DAY<=265:
+ elif ZODIAC_DAY <= 265:
return 'virgo'
- elif ZODIAC_DAY<=295:
+ elif ZODIAC_DAY <= 295:
return 'libra'
- elif ZODIAC_DAY<=325:
+ elif ZODIAC_DAY <= 325:
return 'scorpio'
- elif ZODIAC_DAY<=356:
+ elif ZODIAC_DAY <= 356:
return 'sagittarius'
- elif ZODIAC_DAY<=365:
- return 'capricorn'
else:
- return 'SYSTEM SELF DESTRUCT';
+ return 'capricorn'
+
def interpret_chinese_sign(year):
- CHINESE_ZODIAC={0:'monkey',1:'rooster',2:'dog',
- 3:'pig',4:'rat',5:'ox',
- 6:'tiger',7:'rabbit',8:'dragon',
- 9:'snake',10:'horse',11:'sheep'}
- return CHINESE_ZODIAC[year%12]
+ CHINESE_ZODIAC = {0: 'monkey', 1: 'rooster', 2: 'dog',
+ 3: 'pig', 4: 'rat', 5: 'ox',
+ 6: 'tiger', 7: 'rabbit', 8: 'dragon',
+ 9: 'snake', 10: 'horse', 11: 'sheep'}
+ return CHINESE_ZODIAC[year % 12]
+
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))