subjects

Dropdown Menu

Tuesday 9 February 2021

Comments and Documentation in Python

 

Comments are used to describe the purpose of the code. Comments are ignored

by the Python system. They are used purely to communicate information to a human reader.

# is used to write a comment

Ex: >>> 8 / 5 # division always returns a floating point number
1.6

 

Documenting Code: Python documentation strings (or docstrings) provide a convenient way of

associating documentation with Python modules, functions, classes, and methods.

We use triple quotes like   ‘‘‘    or  “ “ “.

Ex:

def add( ):

    """  This function will add two numbers     """

       a = int(input(“Enter The first number ”))

       b = int(input(“Enter the second number”))

       print(“Sum of  two numbers is”, a+b)


No comments:

Post a Comment