Lazy programming Series – Comments, Escape Sequence and Print statement | Simple Calculator
In Python, comments, escape sequences, and the print
statement are important elements for writing clear and functional code.
Comments: Comments are used to add explanatory notes within the code. They are not executed by the Python interpreter. You can use either the #
symbol for single-line comments or triple quotes ('''
or """
) for multi-line comments.
Escape Sequences: Escape sequences are used to represent characters that are difficult or impossible to type directly. They start with a backslash (\
) followed by a specific character.
Print Statement: The print
statement is used to display output on the console. You can print variables, strings, and combine them within the print
statement.
In Python 2, print
is a statement, while in Python 3, it is a function. The examples above are based on Python 3.
Remember that clear and concise code with meaningful comments can improve the readability of your Python programs.
Comment for Single line: #
Comment for Multi line: ”’ ……………….
………………..
………………..
”’
If we want to print multiple print statements in the same line
print(“………………”, end=”….”)
‘\t\ -> for the tab
‘\n’ -> for new line
Simple Calculator: