当前位置:网站首页>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:
边栏推荐
- FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
- Analysis of usage scenarios of mutex, read-write lock, spin lock, and atomic operation instructions xaddl and cmpxchg
- Download install and create/run project for HBuilderX
- 工程制图复习题
- Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
- KunlunBase 1.0 is released!
- Deng Qinglin, Alibaba Cloud Technical Expert: Best Practices for Disaster Recovery across Availability Zones and Multiple Lives in Different Locations on the Cloud
- GraphQL背后处理及执行过程是什么
- TensoFlow学习记录(二):基础操作
- 【虚拟户生态平台】虚拟化平台安装时遇到的坑
猜你喜欢
随机推荐
C语言:学生管理系统(链表版)
MySQL回表指的是什么
Flask Framework Beginner-05-Command Management Manager and Database Use
LeetCode third topic (the Longest Substring Without Repeating Characters) trilogy # 3: two optimization
- heavy OpenCV 】 【 mapping
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
内网穿透-应用
boot issue
多线程 之 JUC 学习篇章一 创建多线程的步骤
【store商城项目01】环境准备以及测试
GNSS文章汇总
VR panorama shooting online exhibition hall, 3D panorama brings you an immersive experience
一篇文章看懂JS闭包,从执行上下文角度解析有趣的闭包
nodejs切换版本使用(不需要卸载重装)
LDO investigation
FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
ASP.NET 获取数据库的数据并写入到excel表格中
敏捷交付的工程效能治理
多渠道打包
Is there any jdbc link to Youxuan database documentation and examples?