下载此文档

计算机编程简介.ppt


文档分类:IT计算机 | 页数:约80页 举报非法文档有奖
1/80
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/80 下载此文档
文档列表 文档介绍
Python Programming, 1/e 1 Python Programming: An Introduction to Computer Science Chapter 6 Defining Functions Python Programming, 1/e 2 Objectives ? To understand why programmers divide programs up into sets of cooperating functions. ? To be able to define new functions in Python. ? To understand the details of function calls and parameter passing in Python. / 天津塔吊租赁,河北塔吊租赁,西安塔吊租赁,塔吊租赁 / Python Programming, 1/e 3 Objectives (cont.) ? To write programs that use functions to reduce code duplication and increase program modularity. Python Programming, 1/e 4 The Function of Functions ? So far, we ’ ve seen four different types of functions: ? Our prise a single function called main(). ? Built-in Python functions (abs) ? Functions from the standard libraries () ? Functions from the graphics module (()) Python Programming, 1/e 5 The Function of Functions ? In the code on page 166, the code for drawing the bars occurs in two different places. ? The first bar is drawn immediately before the loop. ? The remaining bars are drawn within the loop. Python Programming, 1/e 6 The Function of Functions ? Having similar or identical code in more than one place has some drawbacks. ? Issue one: writing the same code twice or more. ? Issue two: This same code must be maintained in two separate places. ? Functions can be used to reduce code duplication and make programs more easily understood and maintained. Python Programming, 1/e 7 Functions, Informally ? A function is like a subprogram , a small program inside of a program. ? The basic idea – we write a sequence of statements and then give that sequence a name. We can then execute this sequence at any time by referring to the name. Python Programming, 1/e 8 Functions, Informally ? The part of the program that creates a function is called a function definition . ? When the function is used in a program, we say the definition is called or invoked . Python Programming, 1/e 9 Functions,

计算机编程简介 来自淘豆网www.taodocs.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数80
  • 收藏数0 收藏
  • 顶次数0
  • 上传人274030239
  • 文件大小0 KB
  • 时间2016-04-07