下载此文档

计算机编程简介.ppt


文档分类:IT计算机 | 页数:约80页 举报非法文档有奖
1/80
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/80 下载此文档
文档列表 文档介绍
Python Programming, 1/e 1Python Programming:An Introduction puter ScienceChapter 6Defining FunctionsPython Programming, 1/e 2Objectives To understand why programmers divideprograms up into sets of cooperatingfunctions. To be able to define new functions inPython. To understand the details of functioncalls and parameter passing in Python./ 天津塔吊租赁,河北塔吊租赁,西安塔吊租赁,塔吊租赁 hon Programming, 1/e 3Objectives (cont.) To write programs that use functions toreduce code duplication and increaseprogram Programming, 1/e 4The Function of Functions So far, we’ve seen four different typesof functions: Our prise a single functioncalled main(). Built-in Python functions (abs) Functions from the standard libraries() Functions from the graphics module(())Python Programming, 1/e 5The Function of Functions In the code on page 166, the code fordrawing the bars occurs in two differentplaces. The first bar is drawn immediately beforethe loop. The remaining bars are drawn within Programming, 1/e 6The Function of Functions Having similar or identical code in morethan one place has some drawbacks. Issue one: writing the same code twice ormore. Issue two: This same code must bemaintained in two separate places. Functions can be used to reduce codeduplication and make programs moreeasily understood and Programming, 1/e 7Functions, Informally A function is like a subprogram, a smallprogram inside of a program. The basic idea – we write a sequence ofstatements and then give that sequencea name. We can then execute thissequence at any time by referring tothe Programming, 1/e 8Functions, Informally The part of the program that creates afunction is called a function definition. When the function is used in a program,we say the definition is called Programming, 1/e 9Functions, Informally Happy Birthday lyrics…def main():print "Happy birthday to you!"print "Happy birthday to you!"print "Happy birthday, dear Fred..

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

非法内容举报中心
文档信息
  • 页数80
  • 收藏数0 收藏
  • 顶次数0
  • 上传人drp539604
  • 文件大小0 KB
  • 时间2015-11-21