finalExam_cs8_s13

# finalExam_cs8_s13 - Computer Science 8 Spring 2013 Final...

• Test Prep
• 7

This preview shows page 1 - 5 out of 7 pages.

Computer Science 8 Spring 2013, Final Exam Friday, June 14, 2013 Instructor: Matthew Buoni Name and umail address:________________________/_________________________ Lab time (circle one): 10 11 12 1 2 3 4 5 1. (10 points) What do each of the following expressions display when entered at the Python prompt? : a) >>> 3 // 4 b) >>> 4 // 3 c) >>> 3 % 4 d) >>> 4 % 3 e) >>> '3'*4 f) >>> '3' + '4' g) >>> 5 + 4*3**2 h) >>> [0] + [1] != [1] + [0] i) >>> D = {'a':1, 1:'b', 2:'a', 'b':2} >>> D[2] + D[1] This study resource was shared via CourseHero.com

Subscribe to view the full document.

2. (13 points) Consider the string, s = 'focus aeris whisper helix'. What does the following code display when entered at the Python prompt? (Note: Consider each part independently of the other parts) a) (2 points) >>> s[-2:-5:-2] b) (2 points) >>> s[2:17:5] c) (3 points) >>> L = s.split() >>> u = L[1][:-2] >>> v = L[-2][-2:] >>> print(u + v) d) (3 points) >>> L = s.split() >>> M = [] >>> for w in L: M.append(w[-1]) >>> t = 'i'.join(M) >>> print(t) e) (3 points) >>> p = '' >>> q = True >>> for ch in s: if ch == ' ': q = not q if q: p += ch >>> print(p) This study resource was shared via CourseHero.com
3. (7 points) What does the following Python code display when run?

Subscribe to view the full document.

4. (16 points) The text file 'stocksIN.txt' below and to the left gives the open and close prices for the
• Spring '10
• TaiDat
• Trigraph, sh, ar stu, Digraph, Three points for a win

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern