Python学习笔记(三)函数初识和内置函数
来源:互联网 发布:gif编辑软件 编辑:程序博客网 时间:2024/05/01 08:41
python的函数定义的常规形式如下所示
def function_name(parameters):
block
需要注意的是,python对缩进有严格要求,必须是4个空格,否则会出编译期错误。
没有参数的话直接标()
上代码
#coding=utf-8print("Hello world,my nama is Garfield")
#中文
print("同学们,大家好~")
#函数
print("这是我的第一个函数,用于华氏温度和摄氏温度的转换")
def to_celsius(t):
return (t - 32.0) * 5.0 /9.0
print to_celsius(80)
print to_celsius(78.8)
print to_celsius(10.4)
print("没有参数的函数写法")
def func1():
print("我是没有参数的函数func1")
return
func1()
print("Python的内置函数")
print("转化成字符-----str")
print ("-9的绝对值是"+str(abs(-9)))
print ("4.5四舍五入是"+str(round(4.5)))
print ("2的4次幂是"+str(pow(2,4)))
输出结果如下
- Python学习笔记(三)函数初识和内置函数
- Python学习笔记(三):常用内置函数学习
- [Python学习笔记][Python内置函数]
- python内置函数(三)
- Python学习笔记(14)--python内置函数大全
- Python学习笔记(三)--Python函数
- python内置函数笔记
- Python学习笔记——内置函数
- python 学习笔记之内置函数
- python学习笔记2---内置函数
- python学习笔记(三):常用函数和运算优先级
- 《python入门学习笔记3》(内置函数BIF)
- Python学习:内置函数
- python内置函数学习
- Python内置函数学习
- Python学习-内置函数
- Python学习笔记(三):函数
- Python学习笔记三:函数
- C面试题目3
- 于娟的忠告----生命只有一次,活着才是王道啊!!!
- Hibernate框架学习(简介)
- struts2.xml
- 示波器的触发源和触发方式
- Python学习笔记(三)函数初识和内置函数
- 第05章 数组 03 练习1
- 对工作单元——Unit of Work的理解
- 圆周率的存在
- list和vector区别
- 深入理解Javascript之this关键字
- 01.联系方式验证
- linux shell 终端快捷键
- 02.身份证验证