标签:weight The multi tip with bsp ret height math
1 def add(a, b): 2 print(f"ADDING {a} + {b}") 3 return (a + b) 4 5 6 def subtract(a, b): #subtract :减去的意思 7 print(f"SUBTRACT {a} - {b}") 8 return a - b 9 10 def multiply(a, b): 11 print(f"MULTIPLY {a } * {b}") 12 return a * b 13 14 def divide(a, b): 15 print(f"DIVIDE {a} / {b}") 16 return a / b 17 18 19 print("Let‘s do some math with just function!") 20 age = add(30, 5) 21 height = subtract(78, 4) 22 weight = multiply(90, 2) 23 iq = divide(100, 2) 24 25 print(f"age: {age}, Height: {height}, Weight: {weight}, IQ: {iq} ") 26 27 28 #A puzzle(难题、疑问) for the extra credit,type it in anyway 29 print("Here is a puzzle.") 30 31 #四则混合运算 32 what = add(age, subtract(height, multiply(weight, divide(iq, 2)))) 33 print("That becomes: ",what, "Can you do it by hand? ")
注意在运行该代码时刚开始出现过一次错误:IndentationError: unindent does not match any outer indentation level。百度这条错误原因发现是因为定义函数的时候缩进有问题。但是我的缩进看上去没有问题。如何查看缩进是不是有问题?
在notepad++里面查看缩进:菜单中视图-->显示符号-->显示空格与制表符选项打钩。在查看时注意把notepad++界面最好调成白色比较好。方法:设置菜单->语言格式设置->选择主题(default即可)。
标签:weight The multi tip with bsp ret height math
原文地址:https://www.cnblogs.com/lsc666js/p/13335202.html