# 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!') 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("\\t is a tab: x\ty\tz") 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.") 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.''') input("Press ENTER to continue> ") print("\n") # # no newline # print("After this prints, the cursor stays on the same line ...", end="") print("And now we end the line") 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*********** """)