- 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
推薦閱讀
- Visual Basic .NET程序設計(第3版)
- Mastering Zabbix(Second Edition)
- Java從入門到精通(第5版)
- OpenCV 3和Qt5計算機視覺應用開發
- Koa開發:入門、進階與實戰
- Data Analysis with Stata
- Java EE 7 Development with NetBeans 8
- Scientific Computing with Scala
- Python數據結構與算法(視頻教學版)
- Apache Spark 2.x for Java Developers
- Learning Apache Karaf
- Julia 1.0 Programming Complete Reference Guide
- Instant Debian:Build a Web Server
- C#程序開發參考手冊
- 多接入邊緣計算實戰