- Mastering Python Scripting for System Administrators
- Ganesh Sanjiv Naik
- 113字
- 2021-07-02 14:00:19
Indentation and tabs
Indentation is a must when writing block code in Python. Indentation is useful when you are writing functions, decision-making statements, looping statements, and classes. This makes it easy to read your Python programs.
We use indentation to indicate the block of code in Python programs. To indent a block of code, you can use spaces or tabs. Refer to the following example:
if val1 > val2:
print ("val1 is greater than val2")
print("This part is not indented")
In the preceding example, we indented the print statement because it comes under the if block. The next print statement doesn't come under the if block and that's why we didn't indent it.
推薦閱讀
- Git Version Control Cookbook
- 物聯網系統開發:從0到1構建IoT平臺(第2版)
- 新手學Visual C# 2008程序設計
- Raspberry Pi 2 Server Essentials
- Mastering macOS Programming
- Procedural Content Generation for C++ Game Development
- R數據科學實戰:工具詳解與案例分析
- Python機器學習算法與應用
- Django 5企業級Web應用開發實戰(視頻教學版)
- Oracle數據庫編程經典300例
- OpenCV Android Programming By Example
- WCF全面解析
- 3D Printing Designs:Design an SD Card Holder
- 生成藝術:Processing視覺創意入門
- Java語言GUI程序設計