final_exam.winter_2009

final_exam.winter_2009 - P L E A S E H A N D I N UNIVERSITY...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: P L E A S E H A N D I N UNIVERSITY OF TORONTO Faculty of Arts and Science APRIL/MAY 2009 EXAMINATIONS CSC108H1S Instructor: Horton Duration 3 hours P L E A S E H A N D I N 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 cant 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 contd ... CSC108H1S 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 contd ... APRIL/MAY 2009 Final Examination CSC108H1S 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 pixels 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 contd ... CSC108H1S 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....
View Full Document

Page1 / 21

final_exam.winter_2009 - P L E A S E H A N D I N UNIVERSITY...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online