Sitemap

Python Syntax

2 min readNov 18, 2026

Syntax is know as rules for which we must follow while writing instructions by using Python Programming language. If we dont follow the rules which writing instructions we get Syntax Error

Statement: Statement is nothing but instruction which our python engine can execute and that instruction is called statement,

Get Swetha Pabbathi’s stories in your inbox

Join Medium for free to get updates from this writer.

To write statement we have to follow 3 rules
1. Single statement in single line
2. Multiple Statement in Single line
3. Single statement in Multiple line

  • Single Statement in Single Line: This instruction Python Engine can execute. It means the statement is in single line
    1+1
    2+1
  • Multiple Statement in Single line : It is an optinal rule and we use symbols like Semi column between the statement.
    1+1;2+2;3–3
    print(1+1);print(2+2)print(3–3)
    Whenever programmer is writing the code it should be readable so we must probably use Single statement in Single line
  • Single Statement in Multiple line: We use symbol “\” Backslash or “()” Paranthesis to implement single statement in Multiple line
    Ex: 1+2+4+4–8
    1\
    2\
    4\
    4\
    -8
    Never use “\” backslash at the end, because if we use backslash at the end Python engine thinks that the statement is incomplete and gives an Syntax error.
  • Comment : When the instruction is ignored by the Python Engine then it is know as Comment. We use “#” in front of the statement for Comment. Before the “#” if any statement is there it is executed by python engine but after the “#” if any statement is there then that is ignored by Python Engine.
    Ex: #123 it is ignored any statement is not executed
    123#23 then 123 is executed and 23 is ignored.
    To make the code more readable we use comment in Python Programming
    #Instruction — — — Comment
    Instruction — — — -Statement
  • Keyword: Keywords are reserved words which have a special meaning in Python Engine. Around 35 Keywords we have
  • Variable: Container to store the data i.e collection of information
    __First we will create a data
    __To reuse thhe data we store it
    __We store the data in Container
  • How to create a variable
  • How to store a data
  • How to create a data

We need to follow the syntax to create a variable, store a data, create a data.

Syntax
Variable name = data