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

List Practice A

#Fill in the lines to the right with the output that will be generated by this function
def shoppingLists():
  glist = ['cereal', 'milk', 'water', 'bread', 'cheese', 'lemons']
  slist = ['socks', 'hats', 'gloves', 'shirts', 'belt', 'watch', 'sunglasses']

  print glist                                            #_________________________________
  print glist[0]                                         #_________________________________
  print glist[3:5]                                       #_________________________________
  print glist[3:]                                        #_________________________________
  print glist[:3]                                        #_________________________________
  print glist[-1:]                                       #_________________________________
  print glist[:-1]                                       #_________________________________
  print glist + slist                                    #_________________________________
  print slist[3:5] + glist[3:5]                          #_________________________________
  print slist[5:3:-1] + glist[ len(glist)-1:0:-2]        #_________________________________
  print glist                                            #_________________________________
  print slist                                            #_________________________________
  slist.remove('gloves')                                 #_________________________________
  print slist                                            #_________________________________
  slist.sort()                                           #_________________________________
  print slist                                            #_________________________________
  glist.sort()                                           #_________________________________
  glist.reverse()                                        #_________________________________
  print glist                                            #_________________________________
  newlist = slist + glist                                #_________________________________
  newlist.sort()                                         #_________________________________
  print newlist                                          #_________________________________
  print newlist.count('se')                              #_________________________________
  print newlist.count('Cereal')                          #_________________________________
  print newlist.count('cereal')                          #_________________________________
  print newlist.count('cereal') + glist.count('cereal')  #_________________________________
  print max(newlist)                                     #_________________________________
  print min(newlist)                                     #_________________________________


Links to this Page