博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
think python chapter3
阅读量:4652 次
发布时间:2019-06-09

本文共 1697 字,大约阅读时间需要 5 分钟。

3.1 built-in function

     type(42)=> <class 'int'>

     int('32')=>32

     int(3.9) => 3

     int(-2.3)=>-2

     float(32)=> 32.0

     float('3.14159')=>3.14159

     str(32) => '32'

     str(3.14159)=>'3.14159'

3.2 define a function

Defining a function creates a function object, which has type function.

you have to create a function before you can run it. In other words, the function definition has to run before the function gets called. 

The rules for function names are the same as for variable names: letters, numbers and underscore are legal, but the first character can’t be a number.  

Single quotes and double quotes do the same thing; most people use single quotes except in cases like this where a single quote (which is also an apostrophe) appears in the string. 

Function definitions get executed just like other statements, but the effect is to create function objects. The statements inside the function do not run until the function is called, and the function definition generates no output. 

3.3 flow of execution

Execution always begins at the first statement of the program. Statements are run one at a time, in order from top to bottom.

Function definitions do not alter the flow of execution of the program, but remember that statements inside the function don’t run until the function is called. 

A function call is like a detour in the flow of execution. Instead of going to the next state- ment, the flow jumps to the body of the function, runs the statements there, and then comes back to pick up where it left off. 

3.8 Variables and parameters are local

When you create a variable inside a function, it is local, which means that it only exists inside the function. 

转载于:https://www.cnblogs.com/zxpo/p/5374594.html

你可能感兴趣的文章
Linux Supervisor的安装与使用入门
查看>>
创建 PSO
查看>>
JasperReport报表设计4
查看>>
项目活动定义 概述
查看>>
团队冲刺04
查看>>
我的Python分析成长之路8
查看>>
泛型在三层中的应用
查看>>
SharePoint2010 -- 管理配置文件同步
查看>>
.Net MVC3中取得当前区域的名字(Area name)
查看>>
获得屏幕像素以及像素密度
查看>>
int与string转换
查看>>
adb命令 判断锁屏
查看>>
推荐一个MacOS苹果电脑系统解压缩软件
查看>>
1035等差数列末项计算
查看>>
CDMA鉴权
查看>>
ASP.NET MVC Identity 兩個多個連接字符串問題解決一例
查看>>
过滤器与拦截器区别
查看>>
第二阶段站立会议7
查看>>
JAVA多线程
查看>>
delphi 更改DBGrid 颜色技巧
查看>>