☞Comments are statements that you want the interpreter to ignore.
☞It makes the code more understandable.
☞Types of comments are :
➺Single-line comment :- Begin with hash(#) character and terminate at the end of the line.
➺Multiple-line comment :- Begin with """(triple double quotes) or '''(triple single quotes) and terminate with"""(triple double quotes) or '''(triple single quotes) respectively that spans multiple lines.
☞print() function is used to print the output on the screen.
☞Syntax : print(*objects,[sep =' ' or <seperator-string>, end = '\n' or <end-string>])
☞print(10,"inspirewebsoft") :- In this function 10 and "inspirewebsoft" are arguments/objects whereas sep and end arguments default value is passed.
☞How it works ? Lets understand it.
☞ Example :
print("Welcome","to inspirewebsoft") print("We develop a passion for learning")
Output
Welcome to inspirewebsoft We develop a passion for learning
As you can see in above example, two print() statements are written. Always remember that program runs line by line.
First print statement reads the word 'Welcome' and prints it on the screen, then it reads the comma(,)- which states that use the sep argument(default value), hence it will print space character and after that it reads "to inspirewebsoft" , and prints it to the screen after space character. As you can see clearly there in no more argument to read then it uses end argument(default value) and go to the next line.
In the second statement it reads the whole line as it is, because there is no comma or any other character and prints it on the screen
☞It inserts spaces between items automatically because the default value of sep argument is space(' ') character i.e. sep = ' '
☞print() function automatically adds the sep character between the items/objects being printed in a line.
☞You can also give the sep argument to separate the objects/arguments in your own way.
☞ Example :
print(8,"inspirewebsoft",4.5) # By default sep=' ' print(8,"inspirewebsoft",sep="-") # Explicitly sep='-'
Output
8 inspirewebsoft 4.5 8-inspirewebsoft-4.5
☞print() function automatically adds the newline character at the end of a line printed.
☞By default print() takes value for end argument as '\n' - the newline character
☞You can also give the end argument to end the line in your own way.
Example :
print("Welcome to") # By default end ='\n' print("inspirewebsoft") # By default end ='\n' print("Welcome to",end=' ') # Cursor will not move to the next line as end=' ' print("inspirewebsoft") # By default end ='\n'
Output
Welcome to inspirewebsoft Welocome to inspirewebsoft