用python根据2004年算生肖
时间: 2023-07-12 10:40:20 浏览: 134
可以使用Python的年份取余法来计算生肖。具体实现如下:
```python
year = 2004
zodiacs = ["猴", "鸡", "狗", "猪", "鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊"]
zodiac_index = (year - 2004) % 12
zodiac = zodiacs[zodiac_index]
print(zodiac)
```
输出结果为:
```
猴
```
这样就根据年份2004计算出了对应的生肖猴。
阅读全文