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

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

主站蜘蛛池模板: 南陵县| 永善县| 宁安市| 城市| 溧水县| 安乡县| 手游| 五台县| 新邵县| 梨树县| 五台县| 聂荣县| 禄劝| 垫江县| 德兴市| 石狮市| 威信县| 竹北市| 广河县| 达州市| 东平县| 罗源县| 姜堰市| 乌兰察布市| 古田县| 原平市| 威远县| 林甸县| 东兰县| 鞍山市| 青岛市| 历史| 英山县| 福贡县| 静安区| 乐平市| 左贡县| 合阳县| 金平| 阆中市| 礼泉县|