How to add python comments
In computer programming, comments are a line of code that is not read and executed as part of the program. python comments are a programmer-readable explanation or annotation in the source code. comments on the main purpose of making the source code easier for humans to understand.
Single Line Comment
Python hash # character is used to create single line comment.
Syntax
# Single line comment
Example
var1 = 10 # Initializing var1 var2 = 20 # Initializing var2 # Addition total = var1 + var2 print("Total is : ",total) Output: Total is : 30
Multi-Line Comment
Python multi-line comment is a little different from other languages. Multiline comment starts and ends with “”” (double quotes) or ”'(single quotes).
Syntax
"""
Multi-line comment
"""
OR
'''
Multi-line comment
'''
Example
var1 = 10 # Initializing var1 var2 = 20 # Initializing var2 # Addition """ total = var1 + var2 """ total = var1 + var2 print("Total is : ",total) Output: Total is : 30