python习题19

Posted shadowyuriya

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python习题19相关的知识,希望对你有一定的参考价值。

 1 def cheese_and_crackers(cheese_count, boxes_of_crackers):
 2     print(f"You have {cheese_count} cheese!")
 3     print(f"You have {boxes_of_crackers} boxes fo crackers!")
 4     print("Man that‘s enough for a party!")
 5     print("Get a blanknet.
")
 6     
 7     
 8 print("We can just give the function numbers directly:")
 9 cheese_and_crackers(20,30)
10 
11 
12 print("OR, we can use variables from our script:")
13 amount_of_cheeses = 10
14 amount_of_crackers = 50
15 
16 cheese_and_crackers(amount_of_cheeses, amount_of_crackers)
17 
18 
19 print("We can even do math inside too:")
20 cheese_and_crackers(10 + 20, 5 + 6)
21 
22 print("And we can combine the two, variables and math:")
23 cheese_and_crackers(amount_of_cheeses + 100, amount_of_crackers + 1000)
 1 def book_123(book_page, book_jiage,book_zishu):
 2     print(f"这本书一共有 {book_page}页,约{book_zishu}万字。")
 3     print(f"这本书的价格是{book_jiage}元。")
 4 
 5 
 6 print("001:我刚刚买了一本书。")
 7 book_123(50,20,10)
 8 
 9 print("002:我换一种方式说。")
10 page = 50
11 zishu = 20
12 jiage = 10
13 
14 book_123(page, zishu, jiage)
15 
16 print("003:我换一本五倍的书试试。")
17 book_123(page * 5, zishu * 5, 50)
18 
19 print("004:继续。")
20 book_page = int(input(">>>>"))
21 book_jiage = int(input(">>>>"))
22 book_zishu = int(input(">>>>"))
23 
24 book_123(book_page + 1, book_jiage + 1,book_zishu + 1)

 

以上是关于python习题19的主要内容,如果未能解决你的问题,请参考以下文章

Python代码阅读(第19篇):合并多个字典

Python3练习题系列(03)

python 片段19

19道Python列表和元祖的练习题

python3 练习题100例 (十八)托儿所问题

Python练习题 046:Project Euler 019:每月1日是星期天