python水仙花束
时间: 2024-01-11 09:22:39 浏览: 80
以下是判断一个三位数是否为水仙花数的Python代码示例:
```python
x = int(input('请输入一个三位数:'))
m = x // 100
n = x % 100 // 10
c = x % 10
if x == m**3 + n**3 + c**3:
print(x, "是水仙花数")
else:
print(x, "不是水仙花数")
```
运行示例:
```
请输入一个三位数:153
153 是水仙花数
```
相关问题:
1. 如何判断一个数是否为水仙花数?
2. Python中如何获取一个数的个位、十位和百位数字?
3. 请给出一个判断四位数是否为水仙花数的代码示例。
阅读全文
相关推荐
![](https://img-home.csdnimg.cn/images/20250102104920.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![py](https://img-home.csdnimg.cn/images/20250102104920.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![py](https://img-home.csdnimg.cn/images/20250102104920.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![py](https://img-home.csdnimg.cn/images/20250102104920.png)
![md](https://img-home.csdnimg.cn/images/20250102104920.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![py](https://img-home.csdnimg.cn/images/20250102104920.png)