第19个python程序:函数和变量
来源:互联网 发布:战地之王步枪之王数据 编辑:程序博客网 时间:2024/05/16 08:50
[root@mysql1 pshell]# cat ex19.py
#!/usr/bin/env Python
#-*-coding:utf-8-*-
def cheese_and_crackers(cheese_count,boxes_of_crackers):
print "you have %d cheeses!" % cheese_count
print "you have %d boxes of crackers!" % boxes_of_crackers
print "man that's enough for a party!"
print "get a blanket.\n"
print "we can just give the function numbers directly:"
cheese_and_crackers(20,30)
print "or,we can use variables from our script:"
amount_of_cheese=10
amount_of_crackers=50
cheese_and_crackers(amount_of_cheese,amount_of_crackers)
print "we can even do math inside too:"
cheese_and_crackers(10+20,5+6)
print "and we can combine the two,variables and math:"
cheese_and_crackers(amount_of_cheese+100,amount_of_crackers+1000)
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]# python ex19.py
we can just give the function numbers directly:
you have 20 cheeses!
you have 30 boxes of crackers!
man that's enough for a party!
get a blanket.
or,we can use variables from our script:
you have 10 cheeses!
you have 50 boxes of crackers!
man that's enough for a party!
get a blanket.
we can even do math inside too:
you have 30 cheeses!
you have 11 boxes of crackers!
man that's enough for a party!
get a blanket.
and we can combine the two,variables and math:
you have 110 cheeses!
you have 1050 boxes of crackers!
man that's enough for a party!
get a blanket.
#!/usr/bin/env Python
#-*-coding:utf-8-*-
def cheese_and_crackers(cheese_count,boxes_of_crackers):
print "you have %d cheeses!" % cheese_count
print "you have %d boxes of crackers!" % boxes_of_crackers
print "man that's enough for a party!"
print "get a blanket.\n"
print "we can just give the function numbers directly:"
cheese_and_crackers(20,30)
print "or,we can use variables from our script:"
amount_of_cheese=10
amount_of_crackers=50
cheese_and_crackers(amount_of_cheese,amount_of_crackers)
print "we can even do math inside too:"
cheese_and_crackers(10+20,5+6)
print "and we can combine the two,variables and math:"
cheese_and_crackers(amount_of_cheese+100,amount_of_crackers+1000)
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]# python ex19.py
we can just give the function numbers directly:
you have 20 cheeses!
you have 30 boxes of crackers!
man that's enough for a party!
get a blanket.
or,we can use variables from our script:
you have 10 cheeses!
you have 50 boxes of crackers!
man that's enough for a party!
get a blanket.
we can even do math inside too:
you have 30 cheeses!
you have 11 boxes of crackers!
man that's enough for a party!
get a blanket.
and we can combine the two,variables and math:
you have 110 cheeses!
you have 1050 boxes of crackers!
man that's enough for a party!
get a blanket.
0 0
- 第19个python程序:函数和变量
- 第18个python程序:命名变量代码函数
- 第4个python程序:变量
- 第5个python程序:变量2
- 第35个python程序:分支和函数
- 第20个python程序:函数和文件
- 第21个python程序:函数可以返回东西
- 第25个python程序
- 第14个python程序:提示和传递
- 第30个python程序:else和if
- 第32个python程序:循环和列表
- 第1个python程序:打印
- 第2个python程序:注释#
- 第7个python程序:打印
- 第8个python程序:还是打印
- 第10个python程序:转义
- 第11个python程序:接收输入
- 第12个python程序:提示输入
- SQL server的 各种约束关系
- Hibernate 的内部执行流程
- live555学习笔记-几个重要对象的生命期
- 恶意代码--样本分析学习资料整理网络地址
- union共用体详解
- 第19个python程序:函数和变量
- 非常实用的10款网站数据实时分析工具
- 图像处理-一阶和二阶导数
- Python核心编程
- 单核处理器、多核处理器、多处理器与多线程编程
- Jenkins编译时遇到的NullPointException(空指针异常)问题解决
- memcached 内存分配(slab和chunk)
- angularJs通过过滤器实现获取数据字典
- ffmpeg常用指令总结