In this article, you will learn some basic concept of Python Syntax format.
Python Syntax – Before moving ahead, let’s know a little bit about Python first program – Hello World
Execute Python Syntax – Syntax refers to the structure of the language. The Syntax of Python language sets the rule which defines how a Python program will be written. In other words, it sets a format to write and handle codes. Python syntax can be executed by writing or simply created a code directly in the Command Line:
>>> print("Hello, World!") Hello, World!
Or by creating a python file on the text editor, using the (.py) file extension, and running it in the Command Line:
Python Indentation – In Python, indentation plays an important role. If we do not be careful regarding indentation, then Python will give us an error. Indentation refers to the whitespaces at the beginning of a line. Generally, for give an indentation to a block of code, either you can press Tab keyword once or press Space keyword four times for per indentation (1 Indentation = Four Space). Python uses indentation to indicate a block of code.
If 10 > 9: print("10 is greater than 9")
Let’s see one more time this same example but now it has Syntax Error.
If 9 > 10: print("9 is less than 10")
Note: In above example, word print is underlined with red line because it is showing an Indentation Error.
Note: Use same number of indentations throughout block of code, otherwise Python will give us an error.
If you find anything incorrect in above discussed topic and have any further question, please comment down below.