Printing in Python

By: Zed A. Shaw Emailed: 1765 times Printed: 2513 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

Printing and formatting the printing is done quite often in any program. This simple python script just shows different ways of printing text and characters in python.

1 print "Mary had a little lamb."
2 print "Its fleece was white as %s." % 'snow'
3 print "And everywhere that Mary went."
4 print "." * 10 # what'd that do?
5
6 end1 = "C"
7 end2 = "h"
8 end3 = "e"
9 end4 = "e"
10 end5 = "s"
11 end6 = "e"
12 end7 = "B"
13 end8 = "u"
14 end9 = "r"
15 end10 = "g"
16 end11 = "e"
17 end12 = "r"
18
19 # watch that comma at the end. try removing it to see what happens
20 print end1 + end2 + end3 + end4 + end5 + end6,
21 print end7 + end8 + end9 + end10 + end11 + end12

What You Should See

$ python
Mary had a little lamb.
Its fleece was white as snow.
And everywhere that Mary went.
..........
Cheese Burger
$


python Home | All python Tutorials | Latest python Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(0)


Be the first one to add a comment

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Zed A. Shaw
Formatted printing in Python
Printing in Python
Strings And Text in Python
Variables And Printing in Python
Variables And Names in Python
Numbers And Math in Python
Comments And Pound Characters in Python
Your First Program in Python
Installing gedit for python programming in Linux
Installing gedit for python programming in Mac OS X

More Tutorials in python
What is the need for Python language?
How to compile python script and create .pyc file?
How to find the current module name in python
How to force rereading of a changed module in python
UnboundLocalError in python
call by reference in python
Callable objects in python
Ternary operator in python
Hexadecimal and Octal integers in python
Convert string to number in python
Convert number to string in python
Perl's chomp() equivalent for removing trailing newlines from strings in python
Convert between tuples and lists in python
Iterate over a sequence in reverse order in python
Remove duplicates from a list in python

More Latest News
Most Viewed Articles (in python )
Printing in Python
Installing gedit for python programming in Windows
Installing gedit for python programming in Linux
Your First Program in Python
Comments And Pound Characters in Python
Numbers And Math in Python
Variables And Names in Python
Variables And Printing in Python
Strings And Text in Python
Formatted printing in Python
Using Unicode Literals in Python
Unknown command: 'migrate'
error: â_mysql_ConnectionObjectâ has no member named
What is the need for Python language?
How to compile python script and create .pyc file?
Most Emailed Articles (in python)
Convert number to string in python
How to force rereading of a changed module in python
Hexadecimal and Octal integers in python
Formatted printing in Python
Ternary operator in python
Convert string to number in python
Remove duplicates from a list in python
Your First Program in Python
Numbers And Math in Python
Variables And Names in Python
error: â_mysql_ConnectionObjectâ has no member named
call by reference in python
Perl's chomp() equivalent for removing trailing newlines from strings in python
Iterate over a sequence in reverse order in python
Schwartzian Transform in python