num = 905;
def is_Palindrome(num):
"""
判断一个数字是不是回文数,这里有些取巧了
:param num:
:return:
"""
"""
:param num:
:return:
"""
temp = "%d"%num;
str = temp[::-1];
if temp == str:
return True;
else:
return False;
def create_Palindrome(num):
"""
用196算法计算指定数字的回文数
:param num:
:return:
"""
count = 0;
while True:
if True == is_Palindrome(num):
output = "这是一个回文数:%d"%num + "rn总共次数为%d"%count;
print(output);
break;
else:
num = add(num);
count += 1;
def add(num):
"""
num 与自己倒序的数字相加
:param num:
:return:
"""
temp = "%d"%num;
str = temp[::-1];
return int(temp) + int(str);
print(create_Palindrome(num));