Computer Science
"Comments are useful and easy way to enhance readability and understandability of a program." Elaborate with examples.
Python Funda
63 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
33 Likes
Related Questions
What is the error in following code : X, Y = 7 ?
Following variable definition is creating problem X = 0281, find reasons.
From the following, find out which assignment statement will produce an error. State reason(s) too.
(a) x = 55
(b) y = 037
(c) z = 0o98
(d) 56thnumber = 3300
(e) length = 450.17
(f) !Taylor = 'Instant'
(g) this variable = 87.E02
(h) float = .17E - 03
(i) FLOAT = 0.17E - 03How will Python evaluate the following expression ?
20 + 30 * 40