Definition and invocation of functions in Python

Source: Internet
Author: User
Tags function definition

1. Why use a function?

(1) Too many code repetitions (2) Poor readability

Benefits of using Functions:

(1) Code reuse

(2) Maintain consistency, easy maintenance

(2) Scalability

2. Initial function definition and invocation

definition of a function

  def Test (x):       " The function Definitions "       x+=1      return x         def : Defines a keyword  for a function "" : Document description (not necessary, but strongly recommend adding descriptive information for your function) x+=1: Refer tocode block or program processing logic return  : Define return value call run: can take parameters or do not have function name ()

Definition and invocation of functions in Python

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.