- Mastering Python Scripting for System Administrators
- Ganesh Sanjiv Naik
- 68字
- 2021-07-02 14:00:29
The return statement
The return statement is used to exit a function. Refer to the following syntax:
return [expression_list]
This statement may contain an expression where a value has to be returned. If there is no expression, then the function will return a None object, as shown in the following example:
def return_value(a):
if a >= 0:
return a
else:
return -a
print(return_value(2))
print(return_value(-4))
Output:
2
4
推薦閱讀
- 演進(jìn)式架構(gòu)(原書(shū)第2版)
- ExtGWT Rich Internet Application Cookbook
- Python數(shù)據(jù)分析入門(mén)與實(shí)戰(zhàn)
- Web交互界面設(shè)計(jì)與制作(微課版)
- DevOps Automation Cookbook
- Java虛擬機(jī)字節(jié)碼:從入門(mén)到實(shí)戰(zhàn)
- Apache Mahout Clustering Designs
- 單片機(jī)C語(yǔ)言程序設(shè)計(jì)實(shí)訓(xùn)100例
- PLC應(yīng)用技術(shù)(三菱FX2N系列)
- Java面向?qū)ο蟪绦蛟O(shè)計(jì)
- Python程序設(shè)計(jì)與算法基礎(chǔ)教程(第2版)(微課版)
- Spring技術(shù)內(nèi)幕:深入解析Spring架構(gòu)與設(shè)計(jì)原理(第2版)
- The Statistics and Calculus with Python Workshop
- 算法超簡(jiǎn)單:趣味游戲帶你輕松入門(mén)與實(shí)踐
- Mastering Python