Lab # 4 Programming with Lists Solution




Understand the Application


Company Jet has just purchased Company Stream. Looking to compile a unified customer database list, a combined sorted customer list is needed to streamline JetStream’s new merger. In this lab we’ll write a program that will consolidate the customer lists from Company Jet and Company Stream to create a composite ordered customer list following certain rules that will be stated in the program specification below.


The Program Spec


Write a program using lists that will merge sorted list one and sorted list two into a third merged sorted list. Keep Company Jet’s original customer list intact as well as Company Stream’s original customer list intact… you never know – royalty divides could be an issue at a later date. Keep in mind that Jet’s company list is most likely larger (longer) or perhaps the same size (or even smaller) than Stream’s company list. In terms of how the comparative list order falls in the merger list is anyone’s guess. Your solution will require indexing logic into the disparate lists to keep track of the sorting process.


The original customer lists can be hardcoded. Keep the original customer lists intact. Create a main function that initializes list one and list two, prints the original two disparate lists and then calls a function jetStream() to produce the merged list. Pass both list one and two as parameters to the function jetStream(). The function jetStream() will return the merged and sorted combined customer list.


Deliverable: Your source code solution and a copy of the run pasted into your source submission file. Be sure to comment out your run so that your .py file will still run in the grader test bed.


Input Error Checking: For simplicity our original customer lists will be a simple correctly formed numeric list (i.e. [1, 2, 3]). An empty customer list is a valid original list. Your program does not need to test for an upper bound limit on the length of the lists.


Test Run Requirements: Submit two runs: one demonstrating that an empty customer list can be processed and one demonstrating a merge of two originally populated customer lists.


Here are some other tips and requirements:


  1. Keep original customer lists intact


  1. Create a function named jetStream(); two original customer lists are input parameters
  2. Display original customer lists before call to jetStream()
  3. Display merged list after call to jetStream()
  4. An empty original customer list is a valid list


Here is a sample run:



List Jet is: [1, 5, 10]


List Stream: [3]


The merged list JetStream: [1, 3, 5, 10]


error: Content is protected !!