T-Th 9:05 |
CS 1110: Introduction to Computing Using Python Fall 2012 |
||||||||||||||||||||||||||||
Main
About: Announcements Staff Consultants Times & Places Calendar Materials: Texts Python Command Shell Terminology Handouts: Lectures Assignments Labs Assessment: Grading Exams Resources: CMS Piazza (link) Piazza (about) AEWs FAQ Python API Style Guide Academic Integrity |
Lists and AssertsThere is a PDF version of these instructions, if you would prefer to have that instead. Just when you had become an expert at string slicing, you discovered another sliceable data type: lists. However, lists are different from strings in that they are mutable. Not only can we slice a list, but we can also change its contents. The purpose of the lab is to introduce you to these new features, and demonstrate just how powerful the list type can be. As with last week, we realize that you have a lot on your plate. You have the first stage of the color models assignment coming up, as well as the first exam. So our goal in this lab is to make it as short as possible while still making sure that you are adequately prepared for the exam. Requirements For This LabThere are no files to download for this lab. For the most of the time you will be playing with the Python interactive prompt. We do ask you to implement some functions below. However, we just want you to write the implementation on a piece of paper (which you will show to the instructor). You do not need to submit any modules, and you do not need to write any unit tests. As always, you should try to finish the lab during your section. However, if you do not finish during section, you have until the beginning of lab next week to finish it. You should always do your best to finish during lab hours; remember that labs are graded on effort, not correctness. List Expressions and CommandsFor this part of the lab, you will work in the Python interactive prompt. Create the following list: lablist = ['H','e','l','l','o',' ','W','o','r','l','d','!']Like a string, this is a list of individual characters. Unlike a string, however, the contents of this list can be changed. Enter the following statements and/or commands in the order they are presented. When you type in expressions, Python will immediately display the value; the commands below are all followed by a print statement showing the new contents of the list. Each case, describe what you see and explain the result.
List FunctionsBelow are two function specifications; implement them. You will probably want to test them out on the computer. However, to turn them in you just need to write the final version on a piece of paper and show it. For each of these functions, you might find the following list methods useful.
|