python 生日日期星座查詢表

利用python達成 輸入月份日期 就可以該生日查詢對應的星座
同事在聊星座至少可以秒查= =

月 = int(input("請輸入月份"))
日 = int(input("請輸入日期"))

def get_constellation(month, date):
    dates = (21, 20, 21, 21, 22, 22, 23, 24, 24, 24, 23, 22)
    constellations = ("摩羯座", "水瓶座", "雙魚座", "牡羊座", "金牛座", "雙子座", "巨蟹座", "獅子座", "處女座", "天秤座", "天蝎座", "射手座", "魔羯座")
    if date < dates[month-1]:
        return constellations[month-1]
    else:
        return constellations[month]

print ((get_constellation(月,日)))

留言

這個網誌中的熱門文章

教你如何看原始碼(以下載伊莉影片區的影片為例) (107/5/22更新)