当前位置:网站首页>实例029:反向输出
实例029:反向输出
2022-08-02 06:16:00 【懒笑翻】
题目:给一个不多于5位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字。
解题:
"""
学习中遇到问题没人解答?小编创建了一个Python学习交流QQ群,可扫文末的推广进群哦
寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书!
"""
n = input('输入一个不多于5位的正整数:')
if '.' in n or int(n) < 0 or len(n) > 5: # 如果是负数或者位数超过5位 这里大家可以试一下第一个判断是否是小数要放在前面的原因?
print("请输入一个不多于5位的正整数")
else:
print('输入的数是%d位数' % len(n))
print(n[::-1]) # 输出字符串所有内容,逆序输出结果:

边栏推荐
猜你喜欢

HCIP 第三天实验

typescript 'props' is declared but its value is never read solution

System.Security.SecurityException: 未找到源,但未能搜索某些或全部事件日志。不可 访问的日志: Security

Node installation and environment variable configuration

File upload vulnerability (2)

CAT1 4G+以太网开发板腾讯云手机微信小程序显示温度和下发控制
![[Dataset][VOC] Eyewear dataset 6000 in VOC format](/img/66/37f76d9ce5d5f68d6ea0e18710fa04.png)
[Dataset][VOC] Eyewear dataset 6000 in VOC format
![[npm install error report collection] - npm ERR! code ENOTEMPTY npm ERR! syscall rmdir](/img/c5/2c42e26e577506573985b30669ca6c.png)
[npm install error report collection] - npm ERR! code ENOTEMPTY npm ERR! syscall rmdir

Ant three sides: MQ message loss, duplication, backlog problem, what are the solutions?

MySql 5.7.38 download and installation tutorial, and realize the operation of MySql in Navicat
随机推荐
Expert Insights | 3 ways to seize innovation opportunities in a downturn
8/1 思维+扩展欧几里得+树上dp
HCIP 第三天实验
MySQL Advanced Statements (1)
MySQL (3)
数据库概论之MySQL表的增删改查1
Dataset:机器学习中常用数据集下载链接集合之详细攻略
[Dataset][VOC] Male and female dataset voc format 6188 sheets
(部分不懂,笔记整理未完成)【图论】差分约束
关于ue4.27像素流送打包后的本地服务器问题
At age 94, pioneer Turing award winner, computational complexity theory, Juris Hartmanis, died
2022年8月计划,着重ue4视频教程
Understand C operators in one article
享年94岁,图灵奖得主、计算复杂性理论先驱Juris Hartmanis逝世
Mining game (C language)
Submit code process
MySQL 5.7 安装教程(全步骤、保姆级教程)
返回文件名问题
In-depth analysis of the initialization of member variables and local variables
MPLS的相关技术