当前位置:网站首页>Example 037: Sorting
Example 037: Sorting
2022-08-04 01:40:00 【lazily】
Title: Sort 10 numbers.
Program Analysis: Same as Example 005.
Code:
Method one:
raw=[]for i in range(10):x=int(input('int%d: '%(i)))raw.append(x)for i in range(len(raw)):for j in range(i,len(raw)):if raw[i]>raw[j]:raw[i],raw[j]=raw[j],raw[i]print(raw)"""* @Author: xiaofang* @Description:Problems encountered during study and no one answered?The editor created a Python learning and communication QQ group, just scan the QR code of the QQ group at the end of the articleLooking for like-minded friends to help each other, there are also good video learning tutorials and PDF e-books in the group!"""
Method Two:
raw = []for i in range(10):x = int(input('int%d: ' % (i)))raw.append(x)print(sorted(raw))
Results:
边栏推荐
- 企业虚拟偶像产生了实质性的价值效益
- 多渠道打包
- nodejs安装及环境配置
- Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
- Apache DolphinScheduler新一代分布式工作流任务调度平台实战-中
- Google Earth Engine - Calculates the effective width of rivers using publicly available river data
- GNSS【0】- 专题
- ThreadLocal
- FeatureNotFound( bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested:
- 安全至上:落地DevSecOps最佳实践你不得不知道的工具
猜你喜欢
5. Scrapy middleware & distributed crawler
114. How to find the cause of Fiori Launchpad routing error by single-step debugging
实例035:设置输出颜色
什么是SVN(Subversion)?
Continuing to pour money into commodities research and development, the ding-dong buy vegetables in win into the supply chain
工程制图复习题
企业虚拟偶像产生了实质性的价值效益
哎,又跟HR在小群吵了一架!
实例041:类的方法与变量
Slipper - virtual point, shortest path
随机推荐
持续投入商品研发,叮咚买菜赢在了供应链投入上
Sticker Spelling - Memory Search / Shape Pressure DP
html select tag assignment database query result
Web APIs BOM- 操作浏览器:swiper 插件
工程制图复习题
实例038:矩阵对角线之和
《Greenplum构建实时数据仓库实践》简介
【日志框架】
【无标题】
无代码7月热讯 | 微软首推数字联络中心平台;全球黑客马拉松...
2022 China Computing Power Conference released the excellent results of "Innovation Pioneer"
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
LeetCode third topic (the Longest Substring Without Repeating Characters) trilogy # 3: two optimization
静态/动态代理模式
实例039:有序列表插入元素
IDEA02:配置SQL Server2019数据库
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
哎,又跟HR在小群吵了一架!
【虚拟化生态平台】虚拟化平台搭建
持续投入商品研发,叮咚买菜赢在了供应链投入上