final_exam.winter_2009

# final_exam.winter_2009 - APRIL/MAY 2009 EXAMINATIONS...

This preview shows pages 1–5. Sign up to view the full content.

PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science APRIL/MAY 2009 EXAMINATIONS CSC 108H1S Instructor: Horton Duration — 3 hours PLEASE HAND IN Examination Aids: None Student Number: Last (Family) Name(s): First (Given) Name(s): Do not turn this page until you have received the signal to start. (In the meantime, please fill out the identification section above, and read the instructions below carefully .) This final examination consists of 10 questions on 21 pages (includ- ing this one). When you receive the signal to start, please make sure that your copy of the examination is complete. Comments and docstrings are not required except where indicated, although they may help us mark your answers. They may also get you part marks if you can’t figure out how to write the code. You do not need to put import statements in your answers. You may not use break or continue on this exam. If you use any space for rough work, indicate clearly what you want marked. Assume all input is valid unless otherwise indicated; there is no need to error-check. Marking Guide # 1: / 8 # 2: / 6 # 3: / 7 # 4: /12 # 5: /12 # 6: / 6 # 7: /10 # 8: /12 # 9: /12 # 10: / 8 TOTAL : /93 Good Luck! Page 1 cont’d . . .

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CSC 108H1S Final Examination APRIL/MAY 2009 Question 1. [8 marks] Complete the following function according to its docstring description. def clump(L, k): ’’’Return a list that is the same as list L, but with the items grouped into sublists of length k (except for the last sublist, which may be shorter). k must be >= 1. Example: clump([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 4) returns the list [[1, 2, 3, 4], [5, 6, 7, 8,], [9, 10]].’’’ Page 2 of 21 cont’d . . .
APRIL/MAY 2009 Final Examination CSC 108H1S Question 2. [6 marks] Complete the following function according to its docstring description. Hint: media.get_pixel lets you get the pixel at desired coordinates from a picture. You can then either get or set the pixel’s colour. def cutout(p1, p2, x, y, h, w): ’’’p1 and p2 are Pictures with the same height and width. Change p1 so that every pixel in a certain rectangle has the same colour as the corresponding pixel in p2. The rectangle to change has its upper-left corner at pixel (x, y), and has height h and width w. The entire rectangle falls within the borders of p1 (and therefore within the borders of p2, since they have the same dimensions).’’’ Page 3 of 21 cont’d . . .

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CSC 108H1S Final Examination APRIL/MAY 2009 Question 3. [7 marks] Read the help for classes Student and Course below. class Student | A student with a surname, first name, student ID, and a set of courses | taken, each with an integer grade. | | Methods defined here: | | __init__(self, surname, first_name, ID) | A new student with the given surname and first_name (strings), and | ID (an int), and with no courses completed. | | average(self) | Return this Student’s average course grade, or -1 if they have | completed no courses.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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