In this chapter, I just add my own comments to all the output.
#!/usr/bin/env python#-*-coding:utf-8-*-defcheese_and_crakers (Cheese_count, boxes_of_crackers):" "The function that defines the cheese_and_crakers reads out two variables and outputs them. " " Print "You have %d cheeses!"%Cheese_countPrint "You have %d boxes of crackers!"%boxes_of_crackersPrint "Man that's enough for a party!" Print "Get a blanket.\n"#you can directly bring the relevant values into this function. Print "We can just give the function numbers directly:"Cheese_and_crakers (20,30)#It is also possible to bring related variables into this function, provided that a number is required. Because the output is formatted,%d is given.Print "OR, We can use the variables from our script:"Amount_of_cheese= 10amount_of_crackers= 50cheese_and_crakers (amount_of_cheese,amount_of_crackers)#You can also use the arithmeticPrint "We can even do math inside too:"Cheese_and_crakers (10+2, 5+6)#You can also use variables to perform operations. Print "And we can combine the two,variables and math:"cheese_and_crakers (Amount_of_cheese+ +, Amount_of_crackers + 1000)
LPTHW Stupid Methodology Python Chapter 19