Computer Science
"Comments are useful and easy way to enhance readability and understandability of a program." Elaborate with examples.
Python Funda
62 Likes
Answer
Comments can be used to explain the purpose of the program, document the logic of a piece of code, describe the behaviour of a program, etc. This enhances the readability and understandability of a program. For example:
# This program shows a program's components
# Definition of function SeeYou() follows
def SeeYou():
print("Time to say Good Bye!!")
# Main program-code follows now
a = 15
b = a - 10
print (a + 3)
if b > 5: # colon means it's a block
print("Value of 'a' was more than 15 initially.")
else:
print("Value of 'a' was 15 or less initially.")
SeeYou() # calling above defined function SeeYou()
Answered By
32 Likes