0% found this document useful (0 votes)
73 views

Python Output Using Print Function

The document discusses using the print() function in Python to output values. It provides the syntax of print() and describes its parameters like value(s), sep, end, and file. It gives examples of printing single values, multiple values separated by spaces, and disabling spaces. It also shows using end to concatenate outputs on the same line.

Uploaded by

Darshan M M
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

Python Output Using Print Function

The document discusses using the print() function in Python to output values. It provides the syntax of print() and describes its parameters like value(s), sep, end, and file. It gives examples of printing single values, multiple values separated by spaces, and disabling spaces. It also shows using end to concatenate outputs on the same line.

Uploaded by

Darshan M M
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Python | Output using print() function

Last Updated: 14-12-2018

The simplest way to produce output is using the print() function where you can pass zero or more
expressions separated by commas. This function converts the expressions you pass into a string before
writing to the screen.
Syntax: print(value(s), sep= ‘ ‘, end = ‘\n’, file=file, flush=flush)
Parameters:
value(s) : Any value, and as many as you like. Will be converted to string before printed
sep=’separator’ : (Optional) Specify how to separate the objects, if there is more than one.Default :’ ‘
end=’end’:  (Optional) Specify what to print at the end.Default : ‘\n’
file :  (Optional) An object with a write method. Default :sys.stdout
flush :  (Optional) A Boolean, specifying if the output is flushed (True) or buffered (False). Default: False
Returns: It returns output to the screen.
Code #1: Using print() function in Python(2.x)

filter_none
edit
play_arrow
brightness_4
# Python 2.x program showing

# how to print data on

# a screen

  

# One object is passed

print "GeeksForGeeks"

  

# Four objects are passed

print "Geeks", "For", "Geeks", "Portal"

  

l = [1, 2, 3, 4, 5]

# printing a list

print l

Output:

GeeksForGeeks
Geeks For Geeks Portal
[1, 2, 3, 4, 5]
 
Code #2 : Using print() function in Python(3.x)
filter_none
edit
play_arrow
brightness_4
# Python 3.x program showing

# how to print data on

# a screen

  

# One object is passed

print("GeeksForGeeks")

  

x =5

# Two objects are passed

print("x =", x)

  

# code for disabling the softspace feature 

print('G', 'F', 'G', sep ='')

  

# using end argument

print("Python", end = '@')  

print("GeeksforGeeks") 

Output:

GeeksForGeeks
x = 5
GFG
Python@GeeksforGeeks
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn
the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python
DS Course.
Recommended Posts:
 Program to print its own name as output
 Output of Python programs | Set 9 (Dictionary)
 Output of Python Programs | Set 22 (Loops)
 Output of Python Programs | Set 24 (Dictionary)
 Generate two output strings depending upon occurrence of character in input string in Python
 Output of Python Programs | (Dictionary)
 Python | Output Formatting
 Python | Testing Output to stdout
 Python | Logging Test Output to a File
 Input and Output in Python
 Python VLC MediaPlayer – Getting Audio Output Devices
 Python VLC Instance - Enumerate the defined audio output devices
 Output of Python Program - Dictionary (set 25)
 Output of Python Program | Set 3
 Output of Python program | Set 5
 Output of Python Program | Set 1
 Print powers using Anonymous Function in Python
 How to widen output display to see more columns in Pandas dataframe?
 Different Input and Output Techniques in Python3
 Biopython - Sequence input/output

ABHISHEK TIWARI 13
Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article
using contribute.geeksforgeeks.org or mail your article to [email protected]. See your article
appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags : 

Python

python-basics

python-input-output

thumb_up
30
To-do  Done

1.5
Based on 12 vote(s)

Improve Article

Please write to us at [email protected] to report any issue with the above content.

Post navigation

Previous

first_page Python | Sort list of dates given as strings


Next

last_pagePython | Pandas Index.equals()

Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.

Load Comments

Most popular in Python

 Python map() function


 Adding new column to existing DataFrame in Pandas
 Iterate over a list in Python
 Python program to convert a list to string
 Read a file line by line in Python

More related articles in Python

 Enumerate() in Python
 How to get column names in Pandas dataframe
 Python String | replace()
 Reading and Writing to text files in Python
 append() and extend() in Python
room5th Floor, A-118,
Sector-136, Noida, Uttar Pradesh - 201305

[email protected]

 Company
 About Us
 Careers
 Privacy Policy
 Contact Us
 Learn
 Algorithms
 Data Structures
 Languages
 CS Subjects
 Video Tutorials
 Practice
 Courses
 Company-wise
 Topic-wise
 How to begin?
 Contribute
 Write an Article
 Write Interview Experience
 Internships
 Videos
@geeksforgeeks , Some rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you
have read and understood our Cookie Policy & Privacy PolicyGot It !

You might also like