用python输出星座
时间: 2024-01-26 16:42:29 浏览: 143
星座.py
以下是一个简单的Python程序,可以根据输入的出生日期输出对应的星座:
```python
month = int(input("请输入出生月份:"))
day = int(input("请输入出生日期:"))
if month == 1:
if day <= 19:
print("摩羯座")
else:
print("水瓶座")
elif month == 2:
if day <= 18:
print("水瓶座")
else:
print("双鱼座")
elif month == 3:
if day <= 20:
print("双鱼座")
else:
print("白羊座")
elif month == 4:
if day <= 19:
print("白羊座")
else:
print("金牛座")
elif month == 5:
if day <= 20:
print("金牛座")
else:
print("双子座")
elif month == 6:
if day <= 21:
print("双子座")
else:
print("巨蟹座")
elif month == 7:
if day <= 22:
print("巨蟹座")
else:
print("狮子座")
elif month == 8:
if day <= 22:
print("狮子座")
else:
print("处女座")
elif month == 9:
if day <= 22:
print("处女座")
else:
print("天秤座")
elif month == 10:
if day <= 23:
print("天秤座")
else:
print("天蝎座")
elif month == 11:
if day <= 22:
print("天蝎座")
else:
print("射手座")
elif month == 12:
if day <= 21:
print("射手座")
else:
print("摩羯座")
else:
print("输入错误,请重新输入!")
```
该程序首先提示用户输入出生月份和日期,然后根据输入的值通过一系列的if-else语句判断对应的星座,并输出结果。
阅读全文