Click for All Topics
#
.Syntax –
# Welcome to edSlash learning.
Example –
# This is a single-line comment
variable = 10 # Another comment on the same line
print(variable)
# Output on the screen
# 10
Example –
We can create multiple lines of comments using multiple hashtags by using # at the start of each line.Syntax –
# Python block to illustrate
# Multi-line comments with multiple hashatgs
# This block of code is temporarily commented out.
# print("This won't be executed.")
# More code...
print('edSlash')
# Output -
# edSlash
(’’’ ‘’’,””” “””)
to create multi-line comments.#
at the beginning of each line.Example –
print('edSlash')
'''
This is a multi-line comment.
It spans multiple lines without the need for # on each line.
These lines are ignored by the Python interpreter during execution.
'''
print("working with multi-line comments")
# Output -
# edSlash
# working with multi-line comments
Example – Docstring using triple – quoted string
def example_function(parameter):
"""
This is a docstring for example_function.
Parameters:
- parameter: The input parameter for the function.
Returns:
- The result of some operation based on the input parameter.
"""
# Function implementation goes here
return result
1. Code Documentation:
2. Collaboration:
3. Debugging:
4. Readability:
5. Future Maintenance:
6. Regulatory Compliance:
Article written by Anurag Dubey, Team edSlash
Office:- 660, Sector 14A, Vasundhara, Ghaziabad, Uttar Pradesh - 201012, India