Python is among the trendy, multi-purpose, and high-level programming languages. Python is used for varied functions i.e. software program improvement, knowledge science, machine studying, synthetic intelligence, deep studying, and again finish improvement. Extra usually, in any programming language, we have to print some knowledge or string on the console. In python, we use the print () perform to print the string or any form of knowledge on the console.
On this article, we are going to see how we will use the print () perform in python for printing functions.
Let’s start this text by printing the hey world in python.
To print the Hiya World in python 3, make use of the print () perform as follows:
And the output is
In contrast to in python 2, we don’t use parenthesis with the print perform. In python 2 it will be like this
And the output is
Moreover, on this article, we are going to observe the python Three syntax.
Let’s print the “Welcome to LinuxHint” by utilizing the print perform.
print(“Welcome to LinuxHint”)
Print identify of the Animals
If you wish to print the identify of the animals, you possibly can print within the following approach:
That is the essential syntax of the print () perform. We are able to use a number of parameters with the print perform. The next are the parameters of the print () perform:
- Objects: Objects point out the objects which might be to be printed within the print () perform.
- Sep: It’s used to separate the objects within the print perform. We are able to use ‘,’ as a sep. the default worth of sep is ‘’.
- Finish: In python, the print perform finish by default with a brand new line ‘n’. You should utilize any worth to finish the python print perform.
Print a number of objects in a single print assertion
Contemplate the animal instance that we used beforehand to print the identify of animals. Beforehand we used a number of print statements to print the identify of animals. On this instance, we print the identify of varied animals in a single print assertion. The animals are objects. The objects are separated by a sep which is ‘,’.
print(“Cow”,”Canine”,”Cat”,”Lion”, sep =’,’)
Within the above line of code cow, canine, cat, and lion are the objects, and ‘,’ is a separator.
Print assertion with finish parameter
As we all know, the print assertion finish with a brand new line by default however we will use any worth to finish the python print assertion. We are able to finish a line with any string or character. Python 2 doesn’t assist it.
For instance, the print assertion ends with ‘!’.
print (“Hiya Everybody”, finish = ‘ ‘)
print (“Welcome to the LinuxHint”, finish = ‘!’)
The print assertion finish with ‘@’
print (“An e mail should include”, finish = ‘@’)
Print clean traces
Python permits us to print the clean traces within the print () perform. Generally we have to print the clean traces. To print the clean traces we use ‘/n’ in python.
Print 6 clean traces. You’ll be able to write it as follows:
or you may also write it as
print (“Hiya Everybody”)
print (“Welcome to the LinuxHint”)
The print () perform is used for printing the strings, objects, characters, and it’s also used for debugging functions. On this article, we’ve got defined the python print () perform and its utilization with a number of examples.
python tuple,python return multiple values from function,python print example,python print variable,python 2.7 print,python print s,how to print backslash in python,python print format,python print function arguments,python function return multiple values,python 3 print format,python print arguments