Given a list of integers write commands to complete the following manipulations of a list.
Let L := [4,1,2,4,3,1,5];
1. Reverse the order of the list : output [5,1,3,4,2,1,4]
2. Double the list : output [4,4,1,1,2,2,4,4,3,3,1,1,5,5]
3. Sum the elements of the list : output 20
4. Split the list in half and put the first half (or slightly more if the length of the list is odd) in a list and the second half in a list : output [[4,1,2,4],[3,1,5]]
5. List the entries in the even positions : output [1,4,1]
6. List the even entries in in the list : output [4,2,4]
7. Sort the entries in the list : output [1,1,2,3,4,4,5]
8. Remove duplicates from the list (keep the same order) : output [4,1,2,3,5]
Write your code in a worksheet. Place your name and student id number at the top.
On the first line of code in the worksheet place the line : L := [4,1,2,4,3,1,5]; and then
write commands to complete the tasks in such a way that if I change the value of L
in your worksheet then the output changes appropriately. Your assignment will be graded
by replacing L by some other list of integers and seeing if what you wrote
completes the given task.
Save your worksheets and upload the file to Moodle. We are having a few problems saving on the lab computers. I am going to not make
this assignment due, but I will roll it into the next assignment on functions
until we can make sure that everything is working properly.