LPTHW Stupid Methodology Python Chapter 19

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.