=

Syntax, Intentation and Comment

Table of Contents

    Syntax

    A syntax defines that how a program would written. Syntax is like a rule that should be followed when writing the code. For example :

    • Using indentation for writing code blocks.
    • Python is case sensitive (John and john are treated differently).
    • Variables donn't need explicit types.
    • It doesn't use ; for line end.

    Indentation

    In python, any number of empty space at the starting in code lines are called Indentation. It is used for difining code block and writing pretty codes.

    Each line within a code block should have equal indentation.

    Comment python
    if a==1:
        print(a)  #indentation
        print("end")#indentation

    Comment

    Comments are the code that doesn't get executed, and commonly used for explaining/understanding the code.
    There are 2 common types of comments -

    1. Single line comment
    2. Multi-line comment

    Single line comment

    Single line comments are used to make only a single as comment. It is done using adding # symbol as first character of comment. Character written after # are considered as a comment.

    Comment python
    # single line comment
    a=1     # single line comment

    Multi-line comment

    Pyhton doesn't have any multi line comment feature, but an unassigned multi-line string works similar like a multi line comment. It can be created with 3 single/double opening and closing quotes. """ """ or ''' '''

    Comment python
    """
        Hey there 
        share it if you find 
        it helpfull, (multi line comment/string)
    """