1# Docstrings are used create your own Documentation for a function or for a class
2# we are going to write a function that akes a name and returns it as a title.
3def titled_name(name):
4 # the following sting is Docstring
5 """This function takes name and returns it in a title case or in other
6 words it will make every first letter of a word Capitalized"""
7 return f"{name}".title()
1def complex(real=0.0, imag=0.0):
2 """Form a complex number
3
4 Args:
5 real (float, optional): The real part. Defaults to 0.0.
6 imag (float, optional): The imaginary part. Defaults to 0.0.
7 """
8 if imag == 0.0 and real == 0.0:
9 return complex_zero
10 ...
11
1#A docstring is a string literal that occurs as the first statement in a module,
2#function, class, or method definition. Such a docstring becomes the __doc__ special
3#attribute of that object.
4#They serve as documentation or explanation to a statement in a function, class or
5#method definition. They are kept in a triple quotation mark.
6
7
8def complex(real=0.0, imag=0.0):
9 """Form a complex number.
10
11 Keyword arguments:
12 real -- the real part (default 0.0)
13 imag -- the imaginary part (default 0.0)
14 """
15 if imag == 0.0 and real == 0.0:
16 return complex_zero
17 ...
18