How to customize functions in python

王林
Release: 2020-05-12 11:33:43
Original
5462 people have browsed it

How to customize functions in python

Custom function syntax:

Python custom function uses def keyword, the general format is as follows:

def 函数名(参数): ... 函数体 ...
Copy after login

The definition of function mainly has the following points :

1. def: keyword representing the function

2. Function name: the name of the function. The function will be called based on the function name in the future

3. Function body: in the function Perform a series of logical calculations, such as: sending emails, calculating the maximum number in [11,22,38,888,2], etc...

4. Parameters: Provide data for the function body

5. Return value: After the function is executed, data can be returned to the caller.

Code example:

# 定义函数 def test_a(): print('hello world') # 调用函数 test_a()
Copy after login

Recommended tutorial:python tutorial

The above is the detailed content of How to customize functions in python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!