Syntax in python
As we learned in the our previous post that Python syntax can be executed by writing directly in the Command Line:
>>> print("Hello, champ!") Hello, champ!
Or we can also create python file on the server, using the .py file extension, and running it in the Command Line:
C:\Users\usman>python myfile.py
Python Indentation
Indentation refers to the spaces at the beginning of a code line. Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important.
Python uses indentation to indicate a block of code.
For example
if 10 > 2: print("ten is greater than two!")
Python will give you an error if you skip the indentation:
For example
if 10 > 2: print("ten is greater than two!")
keep in mind that You have to use the same number of spaces in the same block of code, otherwise Python will give you an error:
For example
if 10 > 2: print("10 is greater than two!") print("10 is greater than two!")
Link: https://Codelikechamp.com
Medium Link: Follow me on Medium
Linkedin Link: Follow me on Linkedin