-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path2-python-comments.py
More file actions
36 lines (33 loc) · 1 KB
/
2-python-comments.py
File metadata and controls
36 lines (33 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#Single-Line Comments
'''
This code is to show an example of a single-line comment
'''
print( 'This statement does not have a hashtag before it' )
#Multi-Line Comments
'''
#use multi #tags
'''
# it is a
# comment
# extending to multiple lines
#Using String Literals
'''
Because Python overlooks string expressions that aren't
allocated to a variable, we can utilize them as comments.
'''
'it is a comment extending to multiple lines'
#Python Docstring
'''
he strings enclosed in triple quotes that come immediately
after the defined function are called Python docstring.
It's designed to link documentation developed for Python modules,
methods, classes, and functions together. It's placed just beneath
the function, module, or class to explain what they perform.
The docstring is then readily accessible in Python
using the __doc__ attribute
'''
def add(x, y):
"""This function adds the values of x and y"""
return x + y
# Displaying the docstring of the add function
print( add.__doc__ )