Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # All the Ways to Print
- # print() and basic string object manipulation
- # 1 argument
- print("Simple, one argument print call")
- x = "Sue"
- print(x)
- # concatenating a larger string as an arg
- print("My name is " + str(x) + ", how do you do?")
- # data conversion specifiers or "string modulo"
- print("I bet there's rich folks %s in a fancy %s" % ("eating", "dining car"))
- # string class .format()
- print("They're probably drinking {} and smoking big {}!".format("coffee", "CIGARS"))
- # concatenation, string modulo, and string.format() call also be used to create new strings as well
- myString = "They're probably drinking {} and smoking big {}!".format("coffee", "CIGARS")
- # print() can take multiple arguments
- # this can NOT create a new string object, it's only for print()
- c = "Cash"
- print("Hello. ", "I'm ", "Johnny ", c, ".", sep="", end=" ") # defaults: sep=" " and end="\n"
- print("Welcome to the show.")
- # other methods you'll see later that also use keyword parameters with default values
- myList.sort(reverse=False) # usually this is what you want so you just leave out reverse parameter
- import datetime
- dt = datetime.timedelta(days=5) # default: weeks=0, days=0, hours=0... etc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement