~2004.Midterm.pdf

6 Pages
61 Views

Department
Computer Science
Course Code
CSC207H1
Professor
Diane Horton

This preview shows pages 1 and half of page 2. Sign up to view the full 6 pages of the document.
Description
CSC207H1F November Midterm 2004 Duration — 50 minutes Student Number: Aids allowed: none Last Name: First Name: CDF login: Lecture: L0101 / L5101 Do not turn this page until you have received the signal to start. (Please fill out the identification section above, and read the instructions below.) Good Luck! # 1: / 4 # 2: / 4 This midterm consists of 5 questions on 6 pages (including this one). When you receive the signal to start, please make sure that your copy is complete.# 3: /10 Comments 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 # 4: / 7 out how to write the code. If you use any space for rough work, indicate clearly what you want marked. # 5: /15 TOTAL: /40 Total Pages = 6 Page 1 cont’d... Question 1. [4 marks] E3 part 3 asked you to write a Python tool SummarizeLog.py, which was called as follows: python SummarizeLog.py [-d startDate endDate] The square brackets indicated that these three arguments were optional. Part (a) [2 marks] What improvement could be made to this interface to make it more conventional or standard? Part (b) [2 marks] How would that have benefitted the programmers who wrote SummarizeLog.py? Question 2. [4 marks] Part (a) [2 marks] What effect does setting a breakpoint have? Part (b) [2 marks] When do the “Step into” and “Step over” buttons cause the same behaviour? Student #: Page 2 of 6 cont’d... Question 3. [10 marks] The following code produces this output: [’hey’, ’dude’, ’lol’, "It’s", ’my’, ’bad’] # Module coolTester.py | # Module myErrors.py from cool import CoolTalker | # An exception indicating that there from myErrors import NoTranslationError | # is no translation for a word. | class NoTranslationError(ValueError): translator = CoolTalker() | def __init__(self): translator.addWord("hey", "hello") | ValueError.__init__(self) translator.addWord("dude", "friend") translator.addWord("bad", "fault") translator.addWord("lol", "ha") sentence = ["hello", "friend", "ha", "It’s", "my", "fault"] newSentence=[] for word in sentence: try: newWord = translator.toCool(word) except NoTranslationError: newWord = word newSentence.append(newWord) print newSentence Write module cool.py. Student #: Page 3 of 6 cont’d... Question 4. [7 marks]
More Less
Unlock Document

Only pages 1 and half of page 2 are available for preview. Some parts have been intentionally blurred.

Unlock Document
You're Reading a Preview

Unlock to view full version

Unlock Document

Log In


OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit