官术网_书友最值得收藏!

Functions in Python

We briefly discussed functions in Python. Functions execute a predefined set of task. print is one example of a function in Python. It enables printing something to the screen. Let's discuss writing our own functions in Python.

A function can be declared in Python using the def keyword. A function could be defined as follows:

def my_func(): 
print("This is a simple function")

In this function my_func, the print statement is written under an indented code block. Any block of code that is indented under the function definition is executed when the function is called during the code execution. The function could be executed as my_func().

主站蜘蛛池模板: 昌黎县| 平顺县| 城口县| 巴东县| 项城市| 昆山市| 宿松县| 普兰县| 若尔盖县| 桂阳县| 孟津县| 静海县| 涪陵区| 台安县| 紫阳县| 金坛市| 垫江县| 宽城| 鹤峰县| 长阳| 孙吴县| 永昌县| 石棉县| 康平县| 闽侯县| 江西省| 九龙县| 福海县| 郑州市| 东源县| 贵港市| 甘洛县| 忻城县| 蒙山县| 潜江市| 监利县| 温州市| 龙口市| 句容市| 柘城县| 逊克县|