Syntax in python

Syntax in python

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
syntax in python

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

🤞 Don’t miss any latest posts!

Please subscribe by joining our community for free and stay updated!!!

IF YOU HAVE ALREADY SUBSCRIBED JUST CLOSE THIS FORM !

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top