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

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

主站蜘蛛池模板: 杨浦区| 林甸县| 资讯 | 泰兴市| 郑州市| 娄烦县| 重庆市| 盖州市| 浦县| 龙江县| 沙雅县| 延边| 济阳县| 久治县| 万荣县| 孝感市| 剑川县| 保亭| 法库县| 宾阳县| 库尔勒市| 海安县| 海城市| 西青区| 长白| 嘉义市| 宿松县| 通榆县| 清水县| 临夏县| 读书| 板桥市| 上蔡县| 冷水江市| 长岛县| 云和县| 文安县| 沙坪坝区| 泗水县| 明星| 镇赉县|