《笨办法学Python》习题21:函数可以返回东西
2018-03-25 16:25
489 查看
def add(a, b): print "ADDING %d + %d" % (a, b) return a + b def subtract(a, b): print "SUBTRACTING %d - %d" % (a, b) return a - b def multiply(a, b): print "MULTIPLYING %d * %d" % (a, b) return a * b def divide(a, b): print "DIVIDING %d / %d" % (a, b) return a / b print "Let's do some math with just functions!" age = add(30, 5) height = subtract(78, 4) weight = multiply(90, 2) iq = divide(100, 2) print "Age: %d, Height: %d, Weight: %d, IQ: %d" % (age, height, weight, iq) # A puzzle for the extra credit, type it in anyway. print "Here is a puzzle." what = add(age, subtract(height, multiply(weight, divide(iq, 2)))) print "That becomes: ", what, "Can you do it by hand?"
相关文章推荐
- 笨方法学Python 习题 21: 函数可以返回东西
- 习题21 函数可以返回某些东西
- 笨办法学python习题21 函数可以返回某些东西
- 笨方法学习Python-习题21: 函数可以返回东西
- 笨方法学习Python 习题21 函数可以返回东西 ---学习记录
- python21 函数可以返回一些东西
- Exercise 21:函数可以返回一些东西
- Learn Python The Hard Way学习(21) - 函数可以返回信息
- 第21个python程序:函数可以返回东西
- .net中的函数可以返回多个值
- 可以返回执行结果的system函数加强版本
- 笨办法21函数的返回值
- 《笨办法学python》加分习题21——我的答案
- 4.定义一个可以接收三个数字的函数,函数体内返回三个数字中最大的数字
- 可以返回函数内部定义的指针
- 函数可以返回结构体的原因
- 函数不能返回临时变量,可以采用输出参数形式
- Effective STL 条款21: 关联容器的strict weak order(让比较函数对相等的值返回false)
- 《笨办法学python》的本人答案,习题 26: 恭喜你,现在可以考试了!
- .net中的函数可以返回多个值了