PYTHON COMMENTS

Python Comments

comments plays a crucial role in any programming language. 
With the help of comments a developer can explain what code is doing.
when others saw the code they able to know what code is doing.
It saves the time. We can use comments to prevent the execution also.

 

There are two types of comments

1. Single line comment

2.Multi line comment
# is used to comment a single line.
"""triple quotes are used to multiline comment"""

Importance of the comments

To understand the following programming what it is doing , we need to see entire program

print("Enter number :")

n = int(input())

p=0

q=1

while(q <= n):

       if(n%q == 0) :

                  p=p+1

       q=q+1

if(p==2) :

       print("given number is prime")

else :

       print("given number is non prime")

We can understand the following program what it is doing by reading the comment #program to check whether given number is prime or not

#program to check whether given number is prime or not

print("Enter number :")

n = int(input())

p=0

q=1

while(q <= n):

       if(n%q == 0) :

                  p=p+1

       q=q+1

if(p==2) :

       print("given number is prime")

else :

       print("given number is non prime")

Python Indentation

  • Indentation is space at the beginning of lines, to specify a block of code.

  • In other programming languages curly braces {} are used to specify block of code.

  • If you  don't follow indentation python will give an error.

  • The number of spaces  up to the programmer but all the lines at beginning must have same space in a block of code.

 Contact Us:

                  codecalculatenr@gmail.com

 

About Us : 

        Code Calculate is the biggest online platform