新计算机编程导论——Python程序设计 教学课件 赵家刚 狄光智 吕丹桔 第2章 使用序列_1(第3次课).pptVIP

新计算机编程导论——Python程序设计 教学课件 赵家刚 狄光智 吕丹桔 第2章 使用序列_1(第3次课).ppt

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Introduction to Computer Programming School of Computer and Information Science Southwest Forestry University 2013.9 Review Chapter 1 sequential programming Use computers to solve problems Essentials of program design Flow chart Program running Problem-solving process Sequential programming Chapter 2 Using Array Array are frequently used in storing data in program design. Almost every kind of programming language provides a array data structure, such as C and Basic provide one-dimensional, multi-dimensional array. Python provides the richest, the most flexible, and the most powerful forms in program design. This chapter describes the array structures (lists, tuples, dictionaries) in Python, and how to use them to achieve simple and powerful programs. 第2章 使用序列 序列是程序设计中经常用到的数据存储方式,几乎每一种程序设计语言都提供了表格数据结构,如C和Basic中的一维、多维数组等。 Python提供的序列类型在所有程序设计语言中是最丰富,最灵活,也是功能最强大的。 本章介绍使用Python中常用的序列结构(列表、元组、字典)来实现一些简单而又功能强大的程序。 2.1 Array Problem [Q2-1] Data sorting Description: Read 5 data from the keyboard, output in ascending order. Solutions 1: Use five variables to store data, compare and sort. 2.1 序列问题 【问题2-1】 数据排序问题 问题描述:由用户从键盘输入五个数据,按升序排序后输出。 解决方案一:用五个变量来存储输入的五个数据,再用一一比较和交换来达到排序的目的。 2.1 序列问题 问题2-1程序: #data sort Ques2_1_0.py x1 = input(请输入第1个元素:) x2 = input(请输入第2个元素:) x3 = input(请输入第3个元素:) x4 = input(请输入第4个元素:) x5 = input(请输入第5个元素:) #将前两个元素排好序 if x1x2: x1,x2=x2,x1 #将前三个元素排好序 if x1x3: x1,x2,x3=x3,x1,x2 elif x2x3: x2,x3=x3,x2 2.1 Array Problem Shortcoming of Solution 1: Need to define many variables to store data The program is not complex, but tedious, error-prone When sorting more data, such as 50, the programming becomes intolerable When sorting even more data, such as 1000, it will be ridiculous to write a program in this way. 2.1 序列问题 解决方案一存在的问题: 需要定义多个变量来存储数据 程序虽不复杂,但很繁琐,写起来容易出错 当待排序数据达到一定量,如50个时,这样的编程方式变得无法忍受 当待排序数据达到一定量,如1000个时,这样的程序无法编,无法看 …… 2.1 Array Problem Solution 2: Use List Analysis: Input ten data, and store them in a list Use pythons so

您可能关注的文档

文档评论(0)

118压缩包课件库 + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档