Knowledge Base‎ > ‎Programming‎ > ‎Python‎ > ‎Python Reference‎ > ‎

print


Related:

 Examples

 
 
print "welcome to python!"

 Description        

 
Outputs text to the screen

 Syntax

 
 
print expression

 Parameters

 
expression - a Python expression - can be a string or a variables or several smaller expressions concatenated with a "+".

Note: In Python all of the expression must be of the same type so if you wish to print some strings with some integers you must convert some of your values (using str or int, etc.) so that they are all the same type, see interpreter session below.

 Interpreter

 Python 2.6.5 (r265:79359, Mar 24 2010, 01:32:55) 

[GCC 4.0.1 (Apple Inc. build 5493)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> print "welcome to python!"

welcome to python!

>>> name = "Molly"

>>> print "hello " + name + " welcome to python!"

hello Molly welcome to python!

>>> total = 2.54

>>> print "hello " + name + " your total is " + str(total)

hello Molly your total is 2.54





Comments