The python--function internal variables are temporary, and when the function returns, the return value can be assigned to a variable.

Source: Internet
Author: User

#coding =utf-8
Print "Let ' s practice everything."
print ' you\ ' d need to know\ ' bout escapes with \ \ Do \ n newlines and \ t tabs. '

Poem = "" "
\tthe Lovely World
With logic so firmly planted
Cannot discern \ n the needs of Love
Nor comprehend passion from intuition
and requires an explanation
\n\twhere there is none.
"""

Print "----------------"
Print Poem
Print "----------------"


five = 10-2 + 3-6
Print "This should is five:%s"% five

Def Secret_formula (started):
Jelly_beans = started * 500
Jars = jelly_beans/1000
Crates = jars/100
Return Jelly_beans, Jars, crates


Start_point = 10000
Beans, jars, crates = Secret_formula (start_point) #函数内部的变量都是临时的, when your function returns, the return value can be assigned to a variable----"You can create a new variable to hold the return value of the function.

Print "With a starting point of:%d"% start_point
Print "We ' d has%d beans,%d jars, and%d crates."% (beans, jars, crates)

Start_point = START_POINT/10

Print "We can also do the This"
Print "We ' d has%d beans,%d jars,%d crates."% Secret_formula (start_point)

The python--function internal variables are temporary, and when the function returns, the return value can be assigned to a variable.

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.