CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
jackfrued

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: jackfrued/Python-100-Days
Path: blob/master/Day01-15/code/Day05/palindrome.py
Views: 729
1
"""
2
判断输入的正整数是不是回文数
3
回文数是指将一个正整数从左往右排列和从右往左排列值一样的数
4
5
Version: 0.1
6
Author: 骆昊
7
Date: 2018-03-02
8
"""
9
10
num = int(input('请输入一个正整数: '))
11
temp = num
12
num2 = 0
13
while temp > 0:
14
num2 *= 10
15
num2 += temp % 10
16
temp //= 10
17
if num == num2:
18
print('%d是回文数' % num)
19
else:
20
print('%d不是回文数' % num)
21
22