Printing is easy in python, print() function is used to print objects on the screen or any other standard output device.
It can take zero or more arguments.
We can use print('programming9') or print("programming9"). Both are valid statements.
print(object(s), sep=' ', end='\n', file=file, flush=flush)
objects= Any values, it will be converted to string before it is printed.
sep= Separator is optional and it is used to separate the objects, default is ' '
end= end is also optional, end describes what to print at end. By default it is new line (line feed) '\n'
file= it also optional, An object with a write method. Default is sys.stdout
flush= flush is optional. A Boolean, specifying if the output is flushed (True) or buffered (False). By default it is False.
#print one object print("programming9.com") #semicolon not required and prints as it is. #print multiple objects print("programming9",".com") #programming9.com #Use any symbol as separator print("programming9","com",sep='.') #programming9.com print("Hello","world",sep=',,,') #output is Hello,,,world
Another example with variables, variable is just a named representation of a location in memory to hold a value or object.
variables doesn't require Datatypes in python.
x=10 print("x=", x) #output is x= 10
Let us see an example for end and sep.
print('p', 'r', 'o', sep=',') print('programming9',end='.') print('com') #output: #p,r,o #programming9.com