Python print() function Last Updated : 10 Jan, 2023 Comments Improve Suggest changes Like Article Like Report The python print() function as the name suggests is used to print a python object(s) in Python as standard output. Syntax: print(object(s), sep, end, file, flush) Parameters: Object(s): It can be any python object(s) like string, list, tuple, etc. But before printing all objects get converted into strings.sep: It is an optional parameter used to define the separation among different objects to be printed. By default an empty string("") is used as a separator.end: It is an optional parameter used to set the string that is to be printed at the end. The default value for this is set as line feed("\n").file: It is an optional parameter used when writing on or over a file. By default,, it is set to produce standard output as part of sys.stdout.flush: It is an optional boolean parameter to set either a flushed or buffered output. If set True, it takes flushed else it takes buffered. By default, it is set to False.Example 1: Printing python objects Python3 # sample python objects list = [1,2,3] tuple = ("A","B") string = "Geeksforgeeks" # printing the objects print(list,tuple,string) Output: [1, 2, 3] ('A', 'B') GeeksforgeeksExample 2: Printing objects with a separator Python3 # sample python objects list = [1,2,3] tuple = ("A","B") string = "Geeksforgeeks" # printing the objects print(list,tuple,string, sep="<<..>>") Output: [1, 2, 3]<<..>>('A', 'B')<<..>>GeeksforgeeksExample 3: Specifying the string to be printed at the end Python3 # sample python objects list = [1,2,3] tuple = ("A","B") string = "Geeksforgeeks" # printing the objects print(list,tuple,string, end="<<..>>") Output: [1, 2, 3] ('A', 'B') Geeksforgeeks<<..>>Example 4: Printing and Reading contents of an external file For this, we will also be using the Python open() function and then print its contents. We already have the following text file saved in our system with the name geeksforgeeks.txt. To read and print this content we will use the below code: Python3 # open and read the file my_file = open("geeksforgeeks.txt","r") # print the contents of the file print(my_file.read()) Output: Example 5: Printing to sys.stderr Python3 # Python code for printing to stderr # importing the package # for sys.stderr import sys # variables Company = "Geeksforgeeks.org" Location = "Noida" Email = "[email protected]" # print to stderr print(Company, Location, Email, file=sys.stderr) Output: Geeksofrgeeks.org Noida [email protected] Comment More infoAdvertise with us Next Article Python print() function D ddeevviissaavviittaa Follow Improve Article Tags : Python Blogathon Python-Built-in-functions Practice Tags : python Similar Reads hex() function in Python hex() function in Python is used to convert an integer to its hexadecimal equivalent. It takes an integer as input and returns a string representing the number in hexadecimal format, starting with "0x" to indicate that it's in base-16. Example:Pythona = 255 res = hex(a) print(res)Output0xff Explanat 2 min read id() function in Python In Python, id() function is a built-in function that returns the unique identifier of an object. The identifier is an integer, which represents the memory address of the object. The id() function is commonly used to check if two variables or objects refer to the same memory location. Python id() Fun 3 min read Python 3 - input() function In Python, we use the input() function to take input from the user. Whatever you enter as input, the input function converts it into a string. If you enter an integer value still input() function converts it into a string.Python input() Function SyntaxSyntax: input(prompt)Parameter:Prompt: (optional 3 min read Python int() Function The Python int() function converts a given object to an integer or converts a decimal (floating-point) number to its integer part by truncating the fractional part.Example:In this example, we passed a string as an argument to the int() function and printed it.Pythonage = "21" print("age =", int(age) 3 min read Python len() Function The len() function in Python is used to get the number of items in an object. It is most commonly used with strings, lists, tuples, dictionaries and other iterable or container types. It returns an integer value representing the length or the number of elements. Example:Pythons = "GeeksforGeeks" # G 2 min read Python map() function The map() function is used to apply a given function to every item of an iterable, such as a list or tuple, and returns a map object (which is an iterator). Let's start with a simple example of using map() to convert a list of strings into a list of integers.Pythons = ['1', '2', '3', '4'] res = map( 4 min read Python - max() function Python max() function returns the largest item in an iterable or the largest of two or more arguments. It has two forms. max() function with objectsmax() function with iterablePython max() function With ObjectsUnlike the max() function of C/C++, the max() function in Python can take any type of obje 4 min read memoryview() in Python The memoryview() function in Python is used to create a memory view object that allows us to access and manipulate the internal data of an object without copying it. This is particularly useful for handling large datasets efficiently because it avoids the overhead of copying data. A memory view obje 5 min read Python min() Function Python min() function returns the smallest value from a set of values or the smallest item in an iterable passed as its parameter. It's useful when you need to quickly determine the minimum value from a group of numbers or objects. For example:Pythona = [23,25,65,21,98] print(min(a)) b = ["banana", 4 min read Python next() method Python's next() function returns the next item of an iterator. Example Let us see a few examples to see how the next() method in Python works. Python3 l = [1, 2, 3] l_iter = iter(l) print(next(l_iter)) Output1 Note: The .next() method was a method for iterating over a sequence in Python 2.  It has 4 min read Like