当前位置:网站首页>实例030:回文数
实例030:回文数
2022-08-02 06:16:00 【懒笑翻】
题目:一个5位数,判断它是不是回文数。即12321是回文数,个位与万位相同,十位与千位相同。
解题:
"""
学习中遇到问题没人解答?小编创建了一个Python学习交流QQ群,可扫文末的推广进群哦
寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书!
"""
n = input("可以输入任意的数字:")
a = 0
b = len(n) - 1
flag = True # 用来标注是否是回文串
while a < b:
if n[a] != n[b]: # 判断对称位置的数是否相同 如果不相同则退出循环并不是回文串
print(n, '不是回文串')
flag = False
break
a, b = a + 1, b - 1
if flag:
print(n, '是回文串')
结果:
边栏推荐
- MySQL - 多表查询与案例详解
- awk语法-01-基础语法(命令、选项、内部变量)
- Nodejs installation tutorial
- (笔记整理未完成)【图论】图的遍历
- 堡垒机、堡垒机的原理
- MySQL high-level statements (1)
- MySQL high-level --- storage engine, index, lock
- 享年94岁,图灵奖得主、计算复杂性理论先驱Juris Hartmanis逝世
- 实验7 MPLS实验
- At age 94, pioneer Turing award winner, computational complexity theory, Juris Hartmanis, died
猜你喜欢
MySQL classic 50 practice questions and the most detailed analysis of the whole network
Technology empowers Lhasa's "lungs", Huawei helps Lalu Wetland Smart Management to protect lucid waters and lush mountains
Xgboost报错 ValueError: Invalid shape: (1650, 2) for label
chrome plugin development guide
[Dataset][VOC] Eyewear dataset 6000 in VOC format
Specified URL is not reachable,caused by :‘Read timed out
Toolbox App 1.25 新功能一览 | 版本更新
APP专项测试:流量测试
zabbix email alarm and WeChat alarm
How the Internet of Things is changing the efficiency of city operations
随机推荐
How the Internet of Things is changing the efficiency of city operations
实验8 VLAN综合实验
Resolving C# non-static field, method or property "islandnum.Program.getIslandCount(int[][], int, int)" requires an object reference
项目开发规范
MySQL驱动jar包的下载--保姆教程
MySql 5.7.38下载安装教程 ,并实现在Navicat操作MySql
Toolbox App 1.25 New Features at a Glance | Version Update
ue先视频教程后深入
MySQL Advanced SQL Statements
GCC编译器技术解析
Toolbox App 1.25 新功能一览 | 版本更新
Reverse resolve dns server
Ant three sides: MQ message loss, duplication, backlog problem, what are the solutions?
每周推荐短视频:为什么产品开发需要数字化?如何做到数字化?
CAT1 4G+Ethernet development board Tencent cloud mobile phone WeChat applet display temperature and delivery control
Project development specification
[npm install error report collection] - npm ERR! code ENOTEMPTY npm ERR! syscall rmdir
request.getSession(), the story
About the local server problem after ue4.27 pixel streaming package
Xgboost报错ValueError:无效的形状:标签(1650 2)