Python-Comment .

In this session i have discussed comment in Python .


The comment is used to provide the information to reader of program . The interpreter in Python ignore the comments . There are two types of comment in Python as follows .

1-Single line comment

2-Multiline comment


1-Single line comment

The single line comment is used to provide the information in a line . It is represented by hash (#) .

In the below program comment is add the two numbers .

Example : Write a program that add two numbers with comment .

 
         # add two numbers
         x=10
         y=20
         sum=x+y
         print("Sum %d"%(sum))

    
    OUTPUT : Sum 30
    

2-Multiline comment

The multiline comment is used to provide the information in more than one line . It is represented by the triple quote like this """ """ . Write you comment inside triple quote.

Example : Write a program that add two numbers with comment .

       
        """This program add the two numbers
        the program use two varibale x
        and y to sum and assign in sum
        variable """
        x=10
        y=20
        sum=x+y
        print("Sum %d"%(sum))
    
    OUTPUT : Sum : 30
    

Welcome to AndroidATPoint.

back image                     next image