- 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
推薦閱讀
- 國際大學(xué)生程序設(shè)計競賽中山大學(xué)內(nèi)部選拔真題解(二)
- OpenDaylight Cookbook
- Mastering phpMyAdmin 3.4 for Effective MySQL Management
- 算法精粹:經(jīng)典計算機科學(xué)問題的Python實現(xiàn)
- Learn WebAssembly
- 單片機C語言程序設(shè)計實訓(xùn)100例
- Building Android UIs with Custom Views
- 51單片機C語言開發(fā)教程
- NGINX Cookbook
- 時空數(shù)據(jù)建模及其應(yīng)用
- Node.js 12實戰(zhàn)
- 大學(xué)計算機基礎(chǔ)實驗指導(dǎo)
- Getting Started with Python
- Visual Basic程序設(shè)計基礎(chǔ)
- 大話代碼架構(gòu):項目實戰(zhàn)版