How to print a simple string?
() Function, the following operating methods in Python 3 of us to use Python print.
Example 1:
To print "Welcome to Linux fans LinuxMi", please use the print () function in the following manner:
print ( "Welcome to Linux fans LinuxMi")
Output:
Welcome to Linux fans LinuxMi
In In Python 2, the same example is shown below
print "Welcome to Linux fans LinuxMi"
Example 2:
If the name of five countries to be printed, you can write:
print("China")
print("Canada")
print("Germany")
print("France")
print("Japan")
Output:
China
Canada
Germany
France
Japan
How to print a blank line
Sometimes you need to print a blank line in Python programs. The following is an example of performing this task.
Example:
Let's print 6 blank lines. You can enter:
print (6 * "\n")
or
print ("\n\n\n\n\n\n\n")
The sample code
print ( "Welcome to Linux fans LinuxMi")
Print (6 * "\ the n-")
print ( "Hello, welcome to Linux fans LinuxMi")
Output is as follows:
linuxmi @ linux: ~ / Linux fans $ python3 LinuxMi.py
Welcome to Linux fans LinuxMi
Hello and welcome to Linux fans LinuxMi
Print end command
By default, Python's print () function newline character ends. This function takes a parameter named "end" of. The default value for this parameter '\ n', i.e., line breaks. You can use this parameter to any character or string end of the print statement. Available only in the Python 3+
Example 1:
print ( "Welcome to Linux fans", End = '')
print ( "LinuxMi", End = '!' \ the n-')
Output:
Example 2:
Output # '@' end.
print("Python,LinuxMi" , end = '@')
Output:
Python,LinuxMi@