CS 1004 Aug 14 2014
Class: Course Evaluations
Think of yourself as a brand. You need to be remembered. What will they remember you for? What defines you? If you have it in you, do something that defines you. Invent something, develop a unique skill, get noticed for something – it creates a talking point.
Chris Arnold
1 Getting Ready For Final Exam
1.1 Skills
We are continuing the process of reviewing the core skills that I used when designing this course.
1.1.1 String Manipulation
SM-1. Know how to convert string into integers and floats
SM-2. Know how to convert floats and integers into string
SM-3. Know how to concatenate string literals
SM-4. Know how to read string input from keyboard
There are two ways. input will convert the entered text into an int, a float, a string, a Boolean, or a list of the same. raw_input returns the exact characters typed in
SM-5. Know how to process XML formatted data
SM-6. Know how to search through a string to find delimited tokens and regions
SM-7. Know how to use ord(char) to determine ASCII code for a character
We did not complete this skill.
SM-8. Know how to use chr(int) to generate character from a given ASCII code
We did not complete this skill.
SM-9. Know how to slice a string substring
1.1.2 Input Output
IO-1. Know how to print information to the console window
IO-2. Know how to read raw input from console as string
IO-3. Know how to write data to a file
IO-4. Know how to read in text data containing strings of text
IO-5. Know how to read in CSV formatted data
IO-6. Understand why opened files need to be closed
IO-7. Know how to append data to a file We did not complete this skill.
IO-8. Know how to use eval to convert arbitrary string into python data type We did not complete this skill, but note that input does this.
1.2 In-Class Exercise
Here are a number of programming questions that you should all be able to do. I encourage you to try solving them all
You are given a list of lists (i.e., something like [ [1, 2, 3], [9, 4], [5, 4, 2, 3] ]) and you are asked to append all individual values to create a single large list [ 1, 2, 3, 9 4, 5, 4, 2, 3].
hint: You can solve this without a nested loop
You have a string representing the pages of a document that you would like to print (i.e., something like ’1,5,16,20-25,33’) where commas separate individual pages as well as regions represented by hyphens. You want to count the total number of integers in the representation. In the above case, there would be ten pages printed.
hint: split will really come in handy here, more than once
Given a list containing only 0s and 1s, determine whether there is a consecutive run of N 1s, where N is the parameter to the function.
1.3 Version : 2014/08/21
(c) 2014, George Heineman