Python learning question ———— How does the return of Python understand?

Source: Internet
Author: User

How does the return of Python understand? The first thing to understand is, what is a function?
The book may say that the function is the module of completion function and so on. In fact, the function is a worker you recruit.
You give him some material, tell him how to use these materials to assemble, then he is responsible for the assembled finished products to you. The material is the function parameter, the finished product is the function output, and how to assemble is the function body code which you write.
For example, this piece of code
def worker (A, B, c):     = A + b    = x * C

The worker, under your guidance, uses a B-c three material to assemble the X and y two finished items.
But the assembly in the program is different from the factory, and the used material does not disappear. In this way, the worker has a b c x y five-like item in his hand. How does he know which one you want?
So the function of return is to tell the worker at this time what you want, whether it's an iphone shell or the entire iphone. For example
def worker (A, B, c):     = A + b    = x * c    return y

So the workers will give y to you. When you let the worker help you work (call the function)

result = Worker (1, 2, 3)

You will get the corresponding result (1+2).

This is the function of return.

Python learning question ———— How does the return of Python understand?

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.