笨办法学python3练习代码ex19.py
Posted lscv26
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了笨办法学python3练习代码ex19.py相关的知识,希望对你有一定的参考价值。
定义函数的语法:
def 函数名(参数)
(语句)
1 #函数和变量
2 #函数里的变量与脚本里的变量是没有联系的。
3 def cheese_and_crackers(cheese_count,boxes_of_crackers):
4 print(f"You have {cheese_count} cheese!")
5 print(f"You have {boxes_of_crackers} boxes of crackers!")
6 print("Man that‘s enough for a party!")
7 print("Get a blanket.
") #blanket :毛毯
8
9
10 print("We can just give the function numbers directly: ")
11 cheese_and_crackers(20,30)
12
13
14 print("OR, We can use variables from our script:")
15 amount_of_cheese = 10
16 amount_of_crackers =50
17 cheese_and_crackers(amount_of_cheese,amount_of_crackers)
18
19
20 print("We can even do math inside too: ")
21 cheese_and_crackers(10 + 20, 5 + 6)
22
23
24 print("And we can combine the two, variable and math: ")
25 cheese_and_crackers(amount_of_cheese + 100, amount_of_crackers + 1000)
以上是关于笨办法学python3练习代码ex19.py的主要内容,如果未能解决你的问题,请参考以下文章
笨办法学python3代码练习ex23.py 字符串字节串字符编码