A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/python/python_print_function.htm below:

Python print() Function

Python print() Function

The Python print() function is used to print data to the standard output device, usually on the console. The data can be a string or any other object. However, the resultant object will be converted into a string before printing it on the console or standard output device.

The print() function is one of the most commonly used built-in functions and can be used for debugging purposes also.

Syntax

The syntax of the Python print() function is as follows −

print(object, sep, end, file, flush)
Parameters

The Python print() function accepts the following parameters −

Return Value

The Python print() function does not return any value.

print() Function Examples

Practice the following examples to understand the use of print() function in Python:

Example: Basic Use of print() Function

The following example shows the basic usage of Python print() function. Here, we are displaying a simple string on the screen.

print("Welcome to Tutorials Point!!")

When we run above program, it produces following result −

Welcome to Tutorials Point!!
Example: print() Function With Multiple Arguments

The print() function can accept multiple items which can be strings, numbers, or any other objects. By default, the items are separated by a space. In the code below, we are displaying two different strings in a single line of output.

print("The best tutorials provided by:" "Tutorials Point!!")

Following is an output of the above code −

The best tutorials provided by:Tutorials Point!!
Example: Printing Formatted String Using print() Function

To print formatted strings, we use an f-string, which is a way of embedding expressions inside string literals using curly braces. The code below demonstrates how to embed expressions within print() function.

OrgName = "Tutorials Point"
location = "India"
print(f"{OrgName} is located in {location}.")

Output of the above code is as follows −

Tutorials Point is located in India.
Example: print() Function With 'sep' Parameter

To separate the objects, we use the "sep" parameter which defines a separator between the items. In the below example, we have used a hyphen as a separator.

print("TutorialsPoint", "is", "located", "in", "India.", sep="-")

Following is an output of the above code −

TutorialsPoint-is-located-in-India.
Example: Printing List Object Using print() Function

In the code below, a list of integers is created and then, with the help of print() function, we display them on the screen.

numericList = [66, 77, 88, 99, 111, 222]
print("Printing the list using print:", numericList)

On executing the above code, following output will be displayed −

Printing the list using print: [66, 77, 88, 99, 111, 222]

python_built_in_functions.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4