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

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().

主站蜘蛛池模板: 青河县| 桂平市| 枞阳县| 增城市| 金坛市| 剑河县| 新河县| 崇仁县| 甘泉县| 青海省| 乳源| 富阳市| 镇远县| 扎兰屯市| 木兰县| 黔东| 雷山县| 随州市| 邢台市| 旬邑县| 增城市| 谷城县| 高碑店市| 连城县| 鲁山县| 南昌县| 潼南县| 合作市| 喀喇沁旗| 芦溪县| 凉山| 扶沟县| 宁阳县| 罗源县| 西峡县| 凌云县| 兴义市| 香港 | 朝阳市| 鄂温| 武川县|