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.\n") 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)
原文地址:https://www.cnblogs.com/shadowyuriya/p/10061380.html
时间: 2024-10-11 07:55:06