当前位置:网站首页>实例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]) # 输出字符串所有内容,逆序输出结果:

边栏推荐
- Expert Insights | 3 ways to seize innovation opportunities in a downturn
- punch day05
- In-depth analysis of the initialization of member variables and local variables
- Connection reset by peer problem analysis
- (Part of it is not understood, and the notes are not completed) [Graph Theory] Difference Constraints
- 第06章 索引的数据结构【2.索引及调优篇】【MySQL高级】
- 交换网络----三种生成树协议
- System.Security.SecurityException: 未找到源,但未能搜索某些或全部事件日志。不可 访问的日志: Security
- APP专项测试:流量测试
- 推出 Space On-Premises (本地部署版) Beta 版!
猜你喜欢

MySQL高级学习笔记

实验7 MPLS实验

Node installation and environment configuration

Xgboost报错ValueError:无效的形状:标签(1650 2)

How does abaqus quickly import the assembly of other cae files?

MySQL 5.7 安装教程(全步骤、保姆级教程)

At age 94, pioneer Turing award winner, computational complexity theory, Juris Hartmanis, died

Nodejs installation tutorial

chrome plugin development guide

PMP新考纲考试内容介绍
随机推荐
HCIP day 3 experiment
解决C#非静态字段、方法或属性“islandnum.Program.getIslandCount(int[][], int, int)”要求对象引用
Vscode connect to remote server "Acquiring the lock on the/home / ~ 'problem
awk语法-01-基础语法(命令、选项、内部变量)
MySQL Advanced Statements (1)
【npm install 报错问题合集】- npm ERR! code ENOTEMPTY npm ERR! syscall rmdir
技术管理三级跳
punch day05
Clapper that can interact with the audience in real time
SphereEx苗立尧:云原生架构下的Database Mesh研发实践
有点奇怪!访问目的网址,主机能容器却不行
【暑期每日一题】洛谷 P3156 【深基15.例1】询问学号
交换部分 VLAN
Leetcode Weekly 304
MPLS的相关技术
love
C# FileInfo类
Py's mlxtend: a detailed guide to the introduction, installation, and usage of the mlxtend library
Ant three sides: MQ message loss, duplication, backlog problem, what are the solutions?
(Part of it is not understood, and the notes are not completed) [Graph Theory] Difference Constraints