Python function return valueThere are two forms: 1 returns a value. 2. Multiple values are returned. Now let's take a look at the returned value.
Def Firstvalue (
A , B
):
C = A + B
Return C
Print Firstvalue (
1 , 2 ) Result: 3
Let's look at the returned values: how can we return multiple values? If a function is called in other languages, only one value can be returned. Maybe I am not familiar with all languages, the language I know can return only one value, while python can return multiple values, which is very convenient.CodeSee:
Def Secondvalue (
A , B
):
C = A + B
Return (
A , B
, C )
X , Y , Z = Secondvalue (
1 , 2 )
Print 'X :' , X , 'Y :' , Y , 'Z :' , Z
It may be a bit simple to write, but some details are also very important. By the way, let's share my experience on how to learn python.
OriginalArticlePlease indicate Reprinted from Old Wang python, this article address: http://www.cnpythoner.com/post/111.html
Author: Old Wang @ Python tutorial Old Wang Python provides pythn-related Django tutorials and Python downloads. I hope you will like it!