20101_t2 - CSC108H1S 2010 Test 2 Duration 35 minutes Aids...

Info iconThis preview shows pages 1–3. 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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSC108H1S 2010 Test 2 Duration 35 minutes Aids allowed: none Student Number: Last Name: First Name: Lecture Section: L0101 Instructor: Horton Do not turn this page until you have received the signal to start. (Please fill out the identification section above, write your name on the back of the test , and read the instructions below.) Good Luck! This midterm consists of 4 questions on 6 pages (including this one). When you receive the signal to start, please make sure that your copy 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. No error checking is required: assume all user input and all argument values are valid. If you use any space for rough work, indicate clearly what you want marked. # 1: / 3 # 2: / 5 # 3: / 6 # 4: / 9 TOTAL : /23 Total Pages = 6 Page 1 contd . . . CSC108H1S Test 2 Winter 2010 Question 1. [3 marks] For each of the following snippets of code, write the output that it would produce, or write Error if it would cause an error. Code Output (or Error) d1 = { [1, 2]: "a", [3]: "z" } print d1.keys() d2 = { 1: 2, 5: 9, -3: 4 } ans = 1 for k in d2: ans = ans * k print ans d3 = { "hello": "goodbye", "fee": "fi" } print d3["hello"].upper()[5] + "am"print d3["hello"]....
View Full Document

This note was uploaded on 09/19/2011 for the course CSC 108 taught by Professor Gries during the Fall '08 term at University of Toronto- Toronto.

Page1 / 6

20101_t2 - CSC108H1S 2010 Test 2 Duration 35 minutes Aids...

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

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