Beginner Print
The print statement is an in-built method in python to send textual data to the standard output, i.e., terminal or command prompt.
The primary usage of the print statement is straightforward.
Hello, Python!
You can use the print statement for a variety of different purposes.
My name is John, John Doe
You can separate multiple arguments using a comma(,) when using the print statement.
John Doe
You can also join multiple arguments using a separator. To do so, use the sep argument at the end of the print statement. We haven't covered functions and parameters yet, but it will become evident once we go over them. For now, let's follow the example below.
John:Doe:johnndoe:46:21/01/1974
Before discussing the end argument, we need to know a bit about the whitespace characters. Whitespace characters are not visible to the end-user but do perform a specific function.
The following are whitespace characters:
Newline character is equivalent to pressing the "enter" key while editing a document. It simply moves the cursor to the beginning of the following line.
1
2
3
"\t" does what pressing the "Tab" key does. It just simply moves the cursor to the next Tab stop.
1 2 3
If you might have noticed, the print statement always prints a newline after printing each of the arguments. Sometimes, we want to avoid or emit some other character in place of the default newline.
To do so, pass the intended value to the end argument.
Hello, World!
In this chapter, we learned the usage and importance of the print statement, along with some of its arguments.