Doc String in python
DocStrings
The first string after the function header is called the docstring and is short for documentation string. It is used to explain in brief, what a function does. We generally use triple quotes so that docstring can extend up to multiple lines. This string is available to us as __doc__ attribute of the function. This string should be the first string of function
Program on doc string
def put():
""" welcome to doc string example this is in triple quotes
this is was accessd by a __doc__ this ends with triple quotes and
this string should be the first string of function
By D.G.Prasad
Vision Computers
"""
a=10
b=20
c=a+b
print("sum ",c)
put()
print(put.__doc__)
find the factorial value using recursive function
def fact(x):
if x==1:
return 1
else:
return(x*fact(x-1))
a=int(input("Enter number"))
print("FActrorial ",fact(a))
For
More Explanation
&
Online Classes
Contact Us: +919885348743
More Explanation
&
Online Classes
Contact Us: +919885348743