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

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

主站蜘蛛池模板: 西乌珠穆沁旗| 新干县| 隆化县| 正定县| 洛隆县| 湖南省| 漳州市| 梁河县| 舟山市| 曲靖市| 民和| 赞皇县| 大方县| 南开区| 延吉市| 清原| 随州市| 肃南| 调兵山市| 年辖:市辖区| 枞阳县| 新龙县| 原平市| 钦州市| 淳化县| 灵石县| 涡阳县| 东至县| 正镶白旗| 长泰县| 遵化市| 梁河县| 华坪县| 梅州市| 射洪县| 奉节县| 靖西县| 扶绥县| 公主岭市| 兰西县| 都昌县|