用python根据生日判断星座_python如何根据出生日期判断星座(3)

# Python program to display astrological sign

# or Zodiac sign for given date of birth

def zodiac_sign(day, month):

# checks month and date within the valid range

# of a specified zodiac

if month == 'december':

astro_sign = 'Sagittarius' if (day < 22) else 'capricorn'

elif month == 'january':

astro_sign = 'Capricorn' if (day < 20) else 'aquarius'

elif month == 'february':

astro_sign = 'Aquarius' if (day < 19) else 'pisces'

elif month == 'march':

astro_sign = 'Pisces' if (day < 21) else 'aries'

elif month == 'april':

astro_sign = 'Aries' if (day < 20) else 'taurus'

elif month == 'may':

astro_sign = 'Taurus' if (day < 21) else 'gemini'

elif month == 'june':

astro_sign = 'Gemini' if (day < 21) else 'cancer'

elif month == 'july':

astro_sign = 'Cancer' if (day < 23) else 'leo'

elif month == 'august':

astro_sign = 'Leo' if (day < 23) else 'virgo'

elif month == 'september':

astro_sign = 'Virgo' if (day < 23) else 'libra'

elif month == 'october':

astro_sign = 'Libra' if (day < 23) else 'scorpio'

elif month == 'november':

astro_sign = 'scorpio' if (day < 22) else 'sagittarius'

print(astro_sign)

# Driver code

if __name__ == '__main__':

day = 19

month = "may"

zodiac_sign(day, month)

输出:金牛座

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值