- Cloud Native Python
- Manish Sethi
- 153字
- 2021-07-02 19:11:56
Functions
A function is a block of organized, self-contained programs that perform a specific task, which you can incorporate into your own larger programs. They are defined as follows:
# function def functionname(): do something return
These are a few points to remember:
- Indentation is very important in Python programs
- By default, parameters have a positional behavior, and you need to inform them in the same order that they were defined in
Please see the following code snippet example, which showcases functions:
def display ( name ): #This prints a passed string into this function print ("Hello" + name) return;
You can call the preceding function as follows:
display("Manish") display("Mohit")
The following screenshot shows the execution of the preceding display function:

Note that if you have more than one Python version installed on your system, you need to use Python 3 instead of Python, which uses the default version of Python (generally, 2.7.x).
推薦閱讀
- Learning Selenium Testing Tools with Python
- JMeter 性能測(cè)試實(shí)戰(zhàn)(第2版)
- Nginx Essentials
- EPLAN實(shí)戰(zhàn)設(shè)計(jì)
- Python漫游數(shù)學(xué)王國(guó):高等數(shù)學(xué)、線性代數(shù)、數(shù)理統(tǒng)計(jì)及運(yùn)籌學(xué)
- ArcGIS By Example
- Express Web Application Development
- Python機(jī)器學(xué)習(xí)算法與應(yīng)用
- Java并發(fā)編程:核心方法與框架
- 零基礎(chǔ)學(xué)Scratch 3.0編程
- SEO教程:搜索引擎優(yōu)化入門(mén)與進(jìn)階(第3版)
- 實(shí)戰(zhàn)Python網(wǎng)絡(luò)爬蟲(chóng)
- Unity 5 Game Optimization
- AI輔助編程Python實(shí)戰(zhàn):基于GitHub Copilot和ChatGPT
- Python程序設(shè)計(jì)現(xiàn)代方法