Python Introductory Basic Tutorial 08 form participation arguments for functions

Source: Internet
Author: User

Formal participation arguments for functions

When a function is defined, the variable is called the formal parameter of the function, and the formal parameter is the external value of the function receiving function passed into the function body to deal with, is the interface of function and external program or statement. A variable called when a function call is called an argument . Now let's give an example to illustrate the parameters and arguments.

#define FUN:MULTIDEF multi (x, y): z = x * y return z#define main functiondef main (): a = b = 13#functi On ' add ' CALLEDC = multi (A, b) print C#programme entrymain () print ' end! '

The A and B defined in the main function are the two local variables of the main function, the 10th line main calls the Multi function, the variables A and B are placed at the position of the X and y of the Multi function definition, then the value of a is passed to the value of the x,b variable to the y variable, The A and B variables in parentheses in the function call (line 10th) We call the argument variables when the function is called, and the X and y in the function definition (line 2nd) We call the formal parameters.

Thinking and practicing
    1. How do you define functions and variables under python? What is the main difference between a function and a variable defined in the C language?

    2. What do you need to be aware of when modifying global variable values?

    3. How do I check the help documentation for the SQRT function?

    4. Assignment statement x, y, z = 1, 2, 3 What is the result?

    5. Writing the Max and Min functions for two numbers requires a function with a formal parameter.

    6. Writes the sum of two numbers and functions, requiring a function with a formal parameter.

    7. The SUM function is written based on recursion and requires a function with a formal parameter.


This article is from the "Python Training Zhipu Education" blog, so be sure to keep this source http://jeapedu.blog.51cto.com/7878264/1617074

Python Introductory Basic Tutorial 08 form participation arguments for functions

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.