- Python Programming with Raspberry Pi
- Sai Yamanoor Srihari Yamanoor
- 108字
- 2021-07-02 23:48:48
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().
推薦閱讀
- 電氣自動化專業英語(第3版)
- 數據展現的藝術
- GNU-Linux Rapid Embedded Programming
- 自動控制工程設計入門
- Getting Started with Clickteam Fusion
- 構建高性能Web站點
- PostgreSQL 10 Administration Cookbook
- HTML5 Canvas Cookbook
- Cloud Security Automation
- SQL Server數據庫應用基礎(第2版)
- Introduction to R for Business Intelligence
- 工業機器人入門實用教程
- Arduino創意機器人入門:基于ArduBlock(第2版)
- Data Science with Python
- 計算機導論:實訓篇(第2版)