Comments are used to write something which the programmer does not want to execute. Comments can be written to mark author name, date when the program is written, adding notes for your future self, etc.
There are two types of comments in Python Language -:
Single Line Comment: Single Line comments are the comments which are written in a single line, i.e., they occupy the space of a single line.
import os #This is a comment print("Main code started") #Now I will write my code here: print(os.listdir())
Multi-Line Comment: Multi-Line comments are the comments which are created by using multiple lines, i.e., they occupy more than one line in a program.
import os '''This is a comment Author: Harry Date: 27 November 2020 Multi-line comment ends here ''' print("Main code started") #Now I will write my code here: print(os.listdir())
print() is a function in Python that allows us to display whatever is written inside it. In case an operation is supplied to print, the value of the expression after the evaluation is printed in the terminal. For example,
import os import flask # print statement for printing strings print("Harry is a programmer") # Print statement with a literal print(1+87) #This will print "Harry is a programmer" and 88 on the screen respectively!
end: end argument allows us to put something at the end of the line after it is printed. In simple words, it allows us to continue the line with " " or ',' or anything we want to put inside these quotes of the end.
It simply joins two different print statements using some string or even by space. Example:
import os import flask # print statement for printing strings print("Harry is a programmer", end="**") # Print statement with a literal print(1+87) #This will print "Harry is a programmer**88" on the screen
Some more examples of escape sequence characters are shown below:
|\n||Inserts a new line in the text at the point|
|\\||Inserts a backslash character in the text at the point|
Inserts a double quote character in the text at that point
|\'||Inserts a single quote character in the text at that point|
Inserts a tab in the text at that point
|\f||Inserts a form feed ln the text at that point|
Inserts a carriage return in the text at that point
|\b||Inserts a backspace in the text at that point|
#Please dont remove this line """ This is a Multiline Comment """ """ This is a comment """ # print("Subscribe CodeWithHarry now","Bhai video bhi like kar dena") # print("next line") # print("C:\'narry") print("Harry is \n good boy \t1") #comment after statement
harry sirg aap kamal ho sir. isse achha tutoriel maine kabhi nhi dekha, maine aaj hi join kiya hai aapka channel . aise hi sir bante rhe videos. god bless you sir
Full Notes and Source Code: https://github.com/Optimized-World/Complete-Python-Tutorial-and-Notes
I started this python playlist 2 days ago, harry bhai you are great, thank you bhai aapne bhot ache se explain kiya hai thank you so much
How to enlarge screen window in pycharm
Sir aap great ho
sir in windows power shell, PyCharm and IDLE of Python the output by \r is different. code:print("\t hello \r mudit") Pycharm:mudit Wind Power Shell:mudit hello IDLE:hello mudit and if we copy paste from idle then the output is the one i wrote above but in idle it in showing hello mudit.
Any Course related announcements will be posted here