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.

最新文章

  1. Hexo主题实现多级分类显示
  2. php 无限循环
  3. puppet学习:文件夹权限的问题
  4. JSON和JSONP,也许你会豁然开朗,含jQuery用例
  5. Xcode 插件开发
  6. JavaScript: 世界上最被误解的语言|Douglas Crockford
  7. Vxworks、QNX、Xenomai、Intime、Sylixos、Ucos等实时操作系统的性能特点
  8. 已知的CPropertysheet bug: 切换焦点导致无响应
  9. android 使用asm.jar将android手机屏幕投射到电脑
  10. UVA10537 Toll! Revisited
  11. ibatis resultMap 的用法
  12. 关于C++的const对象
  13. Java Web高级编程(四)
  14. MySQL事务以及隔离级别
  15. pdf.js的使用
  16. linux:安装Memcache并使用
  17. IIS:另一个程序正在使用此文件进程无法访问。
  18. PowerDesigner 参照完整性约束(转载)
  19. SpringBoot 配置文件存放位置及读取顺序
  20. Spring中默认bean名称的生成策略/方式修改

热门文章

  1. 1.2CMM/CMMI是什么?
  2. PHP 面向对象及Mediawiki 框架分析(二)
  3. Java 封装、继承、多态
  4. K8s + Flannel 网络架构图
  5. Anaconda创建环境、删除环境、激活环境、退出环境
  6. MyBatis联合查询association使用
  7. 如何检查BioPerl是否正确安装
  8. python中的import一个注意事项
  9. JAVA8新特性——接口定义增强
  10. Myeclipse快捷键(二)