python19 函数和变量
2013-09-06 05:59
387 查看
直接上代码ex19.py
学习要点:
函数的参数值可以通过不同的方式赋值
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)
学习要点:
函数的参数值可以通过不同的方式赋值
相关文章推荐
- 笨方法学Python 习题 19: 函数和变量
- 笨方法学习Python-习题19: 函数和变量
- 笨方法学习Python 习题19 函数和变量 ---学习记录
- python 笔记 函数和变量 《笨办法学Python》习题19 ——12.27
- Learn Python The Hard Way学习(19) - 函数和变量
- Python学习19:函数和变量 Function and variables
- Python 函数与变量--习题19,learn python the hard way
- 笨办法学python习题19 函数和变量
- python函数参数是值传递还是引用传递(以及变量间复制后是否保持一致):取决于对象内容可变不可变
- 关于python中带下划线的变量和函数 的意义
- 笨方法学Python 习题 18: 命名、变量、代码、函数
- 关于python中带下划线的变量和函数 的意义
- Python函数参数传递以及变量作用域
- python函数全局变量和局部变量
- python嵌入C++------ boost.python如何在C++中调用含有不定长参数tuple变量和关键字参数dict变量的函数
- python函数中变量LEGB原则
- python变量可以=函数
- 零基础入门学习Python(19)--函数:我的地盘听我的
- Python字典,函数,全局变量代码解析
- python中带下划线的变量和函数