Programming Tutorials

Printing in Python

By: Zed A. Shaw in python Tutorials on 2011-03-04  

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
$





Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in python )

Latest Articles (in python)