CBSE Class 11 Computer Science Question 71 of 98

Python Programming Fundamentals — Question 33

Back to all questions
33
Question

Question 22

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

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)