# strings and printing # # basics # print "This is a string. Surround it with double quotes." print 'This is a string. Surround it with single quotes.' print "You can use 'single quotes' in a string with double quotes." print 'You can use "double quotes" in a string with single quotes.' print 'hello "there" you!' raw_input("Press ENTER to continue> ") print "\n" # # escaping characters # print "The backslash character \"\\\" makes the character after it be treated as a character, even if it normally has special meaning." print 'Here it is another way: "\"' print "\\\\ is a backslash: \\" print "\\a is an alarm: \a" print " 1234567890123456789012345678901234567890" print "\\t is a tab: x\ty\tz" print "\\b is a backspace: _\b+" raw_input("Press ENTER to continue> ") print "\n" # # handling long lines # print "This is a very, very long \ string that goes on forever and ever, \ just like a lecture that is too long." raw_input("Press ENTER to continue> ") print "\n" # # printing several lines at once # print "This is a very, very long \n\ string that goes on forever and ever, \n\ just like a lecture that is too long. \n\ Notice it is split over several lines, unlike the previous one." print '''This is a very, very long string that goes on forever and ever, just like a lecture that is too long. It too is split over several lines, but doesn't use the "\\n" convention.''' raw_input("Press ENTER to continue> ") print "\n" # # no newline # print "After this prints, the cursor stays on the same line ...", print "And now we end the line" raw_input("Press ENTER to continue> ") print "\n" # # concatenating strings # print "To concatenate strings, use the \"+\" operator:" print "hello + goodbye is " "hello" + "goodbye" print "Now let's be excessively obsequious" print "YESSIR! " * 10 print """ \t\t\t*********** \t\t\t* GOODBYE * \t\t\t*********** """