Write Comment and Multiline Comment in Python

Python Comments

Python syntaxes and scripts are similar to Basic English and Mathematical forms. So that Python is easy to understand. To make the code more understanding we can use comments. Comments are such things that are not executed by the compilers. Programmers have used this line in plain English to understand what operation they did. It will be also easier when the code is given to other persons. Then they will understand the code easily. Comments can be one single line or multiple lines.

To make a line as a comment in Python, we have to use some operators. For single-line comments, we have to use # and for multiple line comments, we have to use triple quotes (''').

Example of Comments:

# add two integer numbers in Python (user input)

a = int(input("Enter Your First Number:"))

#user input 1

b=int(input("Enter Your Second Number: "))

#user input 2



We have added a with b and stored in c

Now we will print the value of c

print("The Sum is",c)

# Done

Python Statements

Python statements are nothing but the instructions but these instructions will be executed by the interpreter. Python has various statements. For example, value =2. Here = is an assignment statement. Other statements are multi-line statements, if statement, while statement, and for statement.

Multi-line statements:

To break one line into two on more lines we have to use the continuation character (/) in python. It is marked by a newline character.

Example 1:

Total = a1 + \
        a2+ \

print (Total)

Example 2:

Result = 10 + 20 + 30 + \
    40 + 50 + 60 + \
    70 + 80 + 90

print (Result)

The line continuation is done by using various brackets. Those are parentheses ( ), brackets [ ], and braces { }. Examples are given below

Example 1:

fruits = ['apple', 

print (fruits)

Example 2:

answer = (1000 - 20 - 30 -
    40 - 50 - 60 -
    70 - 80 - 90)

print (answer)

We have to use a semicolon to put multiple statements into one line. An example is given below

Value1 = 100; Value2 = 200; Value3 = 300

print (Value1)

print (Value2)

print (Value3)

Example of If, For, and While statements are given below,

If statement: If the statement is used for condition checking and when that will match we have to run several operational lines as per our requirement.

a=int(input(“Enter the Number”))

if a>10:
     print("You have entered greater than 10")
     print("You have entered either 10 or less than 10")

For statement: For statement is denoted as a loop. It is used when to have to wok the same operation multiple times.

#this will print the value from 1 to 10

for i in range(1,10):

While statement: While the statement is also denoted as a loop. It is the same as for statement but the syntax is different.

#this will print the value from 1 to 10


while (i<10):