KnowledgeBoat Logo
|

Informatics Practices

"Comments are useful and an easy way to enhance readability and understandability of a program." Elaborate with examples.

Python Funda

3 Likes

Answer

Comments are statements in a script that are ignored by the Python interpreter and therefore, have no effect on the actual output of the code. Comments make the code more readable and understandable for human beings. This makes the revision/modification of the code easier by the original author of the code and also by some new author who has been assigned the responsibility to modify it. They are highly recommended if the script is too complex or if it is to be reviewed by multiple people over an interval of time.

For example,

# Calculate the area of a rectangle
length = 5
width = 3
# Formula: area = length * width
area = length * width
print("Area of the rectangle is:", area)

Answered By

2 Likes


Related Questions