exercise7 more printing

print "Mary had a little lamb."
print "Its fleece was white as %s." % 'snow'
print "And everywhere that Mary went."
print "." * 10   输出10 个.
end1 = "C"
end2 = "h"
end3 = "e"
end4 = "e"
end5 = "s"
end6 = "e"
end7 = "B"
end8 = "u"
end9 = "r"
end10 = "g"
end11 = "e"
end12 = "r"
print end1+end2+end3+end4+end5+end6,
print end7+end8+end9+end10+end11+end12
输出 Cheese Burger

print end1+end2+end3+end4+end5+end6
print end7+end8+end9+end10+end11+end12
没有逗号的 输出 Cheese
	      Burger

正常情况下python的print都是没有标点符号的,然而加上逗号后 输出中间多一个空格

阅读更多

Booklet Printing

02-12

DescriptionnnWhen printing out a document, normally the first page is printed first, then the second, then the third, and so on until the end. However, when creating a fold-over booklet, the order of printing must be altered. A fold-over booklet has four pages per sheet, with two on the front and two on the back. When you stack all the sheets in order, then fold the booklet in half, the pages appear in the correct order as in a regular book. For example, a 4-page booklet would print on 1 sheet of paper: the front will contain page 4 then page 1, and the back will contain page 2 then page 3. nnFront Backnn------------- -------------nn| | | | | |nn| 4 | 1 | | 2 | 3 |nn| | | | | |nn------------- -------------nnnYour task is to write a program that takes as input the number of pages to be printed, then generates the printing order. nnInputnnThe input contains one or more test cases, followed by a line containing the number 0 that indicates the end of the file. Each test case consists of a positive integer n on a line by itself, where n is the number of pages to be printed; n will not exceed 100.nOutputnnFor each test case, output a report indicating which pages should be printed on each sheet, exactly as shown in the example. If the desired number of pages does not completely fill up a sheet, then print the word Blank in place of a number. If the front or back of a sheet is entirely blank, do not generate output for that side of the sheet. Output must be in ascending order by sheet, front first, then back.nSample Inputnn1n14n4n0nSample OutputnnPrinting order for 1 pages:nSheet 1, front: Blank, 1nPrinting order for 14 pages:nSheet 1, front: Blank, 1nSheet 1, back : 2, BlanknSheet 2, front: 14, 3nSheet 2, back : 4, 13nSheet 3, front: 12, 5nSheet 3, back : 6, 11nSheet 4, front: 10, 7nSheet 4, back : 8, 9nPrinting order for 4 pages:nSheet 1, front: 4, 1nSheet 1, back : 2, 3

没有更多推荐了,返回首页