print built-in provides you the simplest way to display output to the user. Whenever you call the “print” command you will need to supply a value to it. This value will be shown to the user.
In other words, print is useful because when your program is running on command prompt in windows (or terminal in Mac/Linux), then print will allow you to show messages to the user on the command prompt (or terminal).
Try running the following code by clicking on the green triangle sign or click on it and press ctrl+enter on your keyboard.
You can provide any kind of text for printing, or a number expression and Python will print the result of the calculation.
When you print ordinary text like the one shown in the examples above, what you’re essentially printing are “strings”. Strings are basically a sequence of characters. They could be a word, a sentence or a paragraph.
You can also provide multiple values to print and by default they
will be separated by a single space.
You can also provide multiple different values to print. Note that you must separate them all with a comma.
If you want to print a string multiple times then Python provides an easy way of achieving that. Notice the program below where we multiply a string by a number. This is called as string multipliers in Python.
In the next chapter, we will study a few more ways of printing text.