Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

String Practice B

#Fill in the lines to the right with the output that will be generated by this function
def string_manipulate():
  string = "Massachusetts"

  print len(string)                    #________________________________
  print min(string)                    #________________________________
  print max(string)                    #________________________________ 
  print string.count("s")              #________________________________
  print string.count('s')              #________________________________
  print string.replace("s","*")        #________________________________
  print string                         #________________________________
  print string.replace("s","*",1)      #________________________________
  print "I am in" + " " + string       #________________________________
  print string.lower()                 #________________________________
  print string.upper()                 #________________________________
  print string.isupper()               #________________________________
  print string.islower()               #________________________________
  print string.capitalize()            #________________________________
  print string.swapcase()              #________________________________
  print string.endswith("s")           #________________________________
  print string.endswith("o")           #________________________________
  print string.startswith("m")         #________________________________
  print string.startswith("M")         #________________________________
  print string.startswith("s")         #________________________________
  print string.find("ssa")             #________________________________
  print string.find("use")             #________________________________
  print string.find("ca")              #________________________________
  print string.rfind("u")              #________________________________
  print string[3:7]                    #________________________________
  print string[0:10]                   #________________________________
  print string[0:19]                   #________________________________
  print string[4:]                     #________________________________
  print string[:2]                     #________________________________
  print string[-1:]                    #________________________________
  print string[:-1]                    #________________________________
  print string[0::2]                   #________________________________
  print string[ len(string)-1::-1]     #________________________________
  print string[::-1]                   #________________________________
  print string.isalpha()               #________________________________
  print string.isdigit()               #________________________________
  printNow(string.split('t'))          #________________________________


Links to this Page