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
What will be the output produced by the following code fragment?
first = 2 second = 3 third = first * second print (first, second, third) third = second * first print (first, second, third)What will be the output produced by following code fragment:
side = int(input('side') ) #side given as 7 area = side * side print (side, area)Find errors in the following code fragment.
a = 3 print(a) b = 4 print(b) s = a + b print (s)Find errors in the following code fragment.
Name = "Prateek" Age = 26 print("your name & age are", Name + Age)