Do not turn this page until you have received the signal to start. In the meantime, please read the instructions below carefully.
|
|
- Gloria Price
- 6 years ago
- Views:
Transcription
1 UNIVERSITY OF TORONTO MISSISSAUGA DECEMBER 2014 FINAL EXAMINATION CSC108H5F Instructor: Zingaro, Petersen, Tong Duration: 3 hours Examination Aids: None Student Number: Family Name(s): Given Name(s): The University of Toronto Mississauga and you, as a student, share a commitment to academic integrity. You are reminded that you may be charged with an academic offence for possessing any unauthorized aids during the writing of an exam. Clear, sealable, plastic bags have been provided for all electronic devices with storage, including but not limited to: cell phones, tablets, laptops, calculators, and MP3 players. Please turn off all devices, seal them in the bag provided, and place the bag under your desk for the duration of the examination. You will not be able to touch the bag or its contents until the exam is over. If, during an exam, any of these items are found on your person or in the area of your desk other than in the clear, sealable, plastic bag; you may be charged with an academic offence. A typical penalty for an academic offence may cause you to fail the course. Please note, you CANNOT petition to re-write an examination once the exam has begun. Do not turn this page until you have received the signal to start. In the meantime, please read the instructions below carefully. This final examination paper consists of 7 questions on 20 pages (including this one). When you receive the signal to start, please make sure that your copy of the final 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. You may tear the API page off the back of this exam. # 1: /23 # 2: /12 # 3: /10 # 4: /12 # 5: / 6 # 6: / 5 # 7: /12 TOTAL: /80 Page 1 of 20 Good Luck! cont d...
2 Question 1. Part (a) [23 marks] If a dependent child is a person under 18 years of age who does not earn $10,000 or more a year, which expression would define a dependent child? a. age < 18 and salary < b. age < 18 or salary < c. age <= 18 and salary <= d. age <= 18 or salary <= Part (b) What are the values of girls, boys, and children after the following code has been executed? girls = 0 boys = 0 children = girls + boys girls = 15 boys = 12 a. 0, 0, 0 b. 0, 0, 27 c. 15, 12, 0 d. 15, 12, 27 Part (c) [3 marks] There are three variables, a, b and c, which have been initialised to integer values. Write code to shift the values in these variables around so that a is given b s original value, b is given c s original value, and c is given a s original value. The following diagram illustrates the direction of the shifts: Page 2 of 20 cont d...
3 Part (d) What will be the value of the variable z after the following code is executed? x = 1 y = 2 z = 3 if x < y: if y > 4: z = 5 else: z = 6 Part (e) Consider the following block of code, where variables a, b, c, and answer each store integer values: if a > b: if b > c: answer = c else: answer = b elif a > c: answer = c else: answer = a Which of the following sets of values for a, b, and c will cause answer to be assigned the value in variable b? a. a = 1, b = 2, c = 3 b. a = 1, b = 3, c = 2 c. a = 2, b = 1, c = 3 d. a = 3, b = 2, c = 1 Part (f) What will be the value of result after the following code is executed? nums1 = [1, -5, 2, 0, 4, 2, -3] nums2 = [1, -5, 2, 4, 4, 2, 7] result = 0 j = 0 while j < len(nums1): if nums1[j]!= nums2[j]: result = result + 1 j = j + 1 Page 3 of 20 Student #: cont d...
4 Part (g) What is the outcome or likely purpose of the following piece of code? result = 0 for j in range(len(number)): if number[j] < 0: result = result + 1 a. to find the smallest number in the list b. to count the negative numbers in the list c. to sum the negative numbers in the list d. to add 1 to each of the negative numbers in the list e. to find the index of the first negative number in the list Part (h) [2 marks] What is the outcome or likely purpose of the following piece of code? Express your answer as a short phrase, like the phrases provided as possible answers in the previous question. result = 0 for count in range(1, num + 1): result = result + count Part (i) [6 marks] We can represent a list of integers as a sequence of elements arranged from left to right, with the first element at the left and the last element at the right. Using this representation, a programmer wishes to move all elements of a list one place to the right, with the rightmost element being wrapped around to the leftmost position, as shown in this diagram. Page 4 of 20 cont d...
5 Here is the code that performs that shift for a list referred to by the name values: length = len(values) old_right = values[length - 1] for j in range(length - 1, 0, -1): values[j] = values[j - 1] values[0] = old_right For example, if values initially contains the integers [1, 2, 3, 4, 5], once the code has executed it would contain [5, 1, 2, 3, 4]. Write code that will undo the effect of the above code. That is, write code that will move all the elements of the list one place to the left, with the leftmost element being wrapped around to the rightmost position. Part (j) [6 marks] Write a function that will be given a list of integers and will use a loop to calculate and return (as a float) the mean (average) of all the integers in the list. Page 5 of 20 Student #: cont d...
6 Question 2. [12 marks] To the right of each segment of code, show the output it generates, or write Error and briefly describe why the code will not run. (Note: Dictionaries don t maintain order, so if a question contains a dictionary, your output may not list keys in the same order as Python generates. That s okay.) L = [1, 2, 3, 4] for index in range(len(l)): L[index] = L[index] ** 2 print(l) L = [1, 2, 3, 4] for index in range(1, len(l), 2): print(index, L[index]) L = [["1", "2"], ["3", "4"]] for innerl in L: for item in innerl: print(item) L = [["1", "2"], ["3", "4"]] for innerl in L: for item in innerl: item = int(item) print(l) def mystery(s): return s + "!" word = "happy holidays" mystery(word) print(word) def subset_sum(l, start, finish): return sum(l[start:finish]) grades = [90, 100, 95, 70, 85] print(subset_sum(grades, 2, 4)) print(grades) Page 6 of 20 cont d...
7 d = {} months = ["Oct", "Nov", "Dec"] days = [31, 30, 31] for m in months: d[m] = days[m] print(d) d = {} months = ["Oct", "Nov", "Dec"] days = [31, 30, 31] for index in range(len(months)): d[months[index]] = days[index] print(d) d = {} L = [1, 3, 1, 1, 2] for index in range(len(l)): d[l[index]] = d.get(l[index], []).append(index) print(d) count = 4 d = { a : (1, 2), b : (3,)} L = [ a, a ] for item in L: d[item] += count count += 1 print(d) The following two questions use a file called ages.csv. Here is the contents of that file: Andrew,5 Margaret,3 Eleanor,1 f = open("ages.csv") ages = {} for line in f: fields = line.strip().split(",") ages[fields[1]] = fields[0] print(list(ages.keys())) f = open("ages.csv") line = f.readline() line = f.readline() while line: print(line.strip()[-1]) line = f.readline() Page 7 of 20 Student #: cont d...
8 Question 3. [10 marks] You will need the following definitions for the functions below: 1. A mention begins and ends with a space or the end of the tweet. 2. A hashtag begins with # and ends with a space or the end of the tweet. Complete each function according to its docstring description. Part (a) [4 marks] def tags_intersect(tweet_list, hashtag1, hashtag2): """ (list of str, str, str) -> bool Return True iff the two hashtags appear in the same tweet for at least one of the tweets in the tweet list. >>> tlist = [ Why so many #list questions on the exam? #smh,... The #108 profs like lists! ] >>> tags_intersect(tlist, #list, #108 ) False >>> tags_intersect(tlist, #smh, #list ) True """ Page 8 of 20 cont d...
9 Part (b) [6 marks] def index_mentions(tweet_list): """ (list of str) -> dict of {str: list of int} Return a dictionary that maps mentions, as keys, to lists of indices as values. The indices are the indices of tweets in the input tweet_list that contain the mention. >>> tlist = make the exam had too much fun writing the exam. ] >>> index_mentions(tlist) : [0, 1, : : [1]} """ Page 9 of 20 Student #: cont d...
10 Question 4. [12 marks] Suppose that we want to test the functions is_valid_tweet and type_token_ratio. For each function, fill in the testcase table below the function description. In each line of the table, describe one test case. Each test case should evaluate a different category of input. Do not write any code. We have given you one test case per function as an example. Part (a) [6 marks] Recall from Assignment 1 that a valid tweet is between 1 and 140 characters. function: Consider the following def is_valid_tweet(tweet): """(str) -> bool The parameter represents a potential tweet. Return True if and only if the potential tweet is no less than 1 and no more than 140 characters long. """ To describe each test case, provide the tweet you would pass to is_valid_tweet, the return value you expect, and the purpose of the test case. Test Case Description tweet Return Value string of 1 character a True Page 10 of 20 cont d...
11 Part (b) [6 marks] def type_token_ratio(text): """(list of str) -> float Precondition: text is non-empty. Each str in text ends with \n and text contains at least one word. Return the Type Token Ratio (TTR) for this text. TTR is the number of different words divided by the total number of words. """ To describe each test case, provide the list of strings you would pass to type_token_ratio, the return value you expect (as an arithmetic expression, if you prefer), and the purpose of the test. While Assignment 2 was highly concerned with clean words (words with no punctuation), do not consider punctuation or tricky white space issues in the tests for this question. Test Case Description text Return Value list with one sentence containing one word [ word\n ] 1 / 1 Page 11 of 20 Student #: cont d...
12 Question 5. Part (a) [2 marks] [6 marks] Consider the following list and sort in progress. L1 = [10, 8, 3, 5, 1] After 1 pass: L1 = [1, 8, 3, 5, 10] After 2 passes: L1 = [1, 3, 8, 5, 10] What type of sort is being demonstrated and what will the list look like after the next (third) pass? a. Bubble sort, L1 = [1, 3, 5, 8, 10] b. Selection sort, L1 = [1, 3, 5, 8, 10] c. Selection sort, L1 = [1, 3, 5, 10, 8] d. Insertion sort, L1 = [1, 3, 5, 8, 10] e. Insertion sort, L1 = [1, 3, 5, 10, 8] How many passes, total, are required to completely sort the list? 1. Three: we re done. 2. Four: one for each item in the list except the last item 3. Five: one for each item in the list 4. Six: one for each item in the list plus a cleanup pass Part (b) Consider the following list and sort in progress. L1 = [9, 16, 1, 8, 5] After 1 pass: L1 = [9, 16, 1, 8, 5] After 2 passes: L1 = [1, 9, 16, 8, 5] What type of sort is being demonstrated and what will the list look like after the next (third) pass? a. Bubble sort, L1 = [1, 8, 9, 16, 5] b. Selection sort, L1 = [1, 8, 9, 16, 5] c. Selection sort, L1 = [1, 5, 9, 16, 8] d. Insertion sort, L1 = [1, 8, 9, 16, 5] e. Insertion sort, L1 = [1, 5, 9, 16, 8] Page 12 of 20 cont d...
13 Part (c) Consider the following list and sort in progress. L1 = [9, 16, 1, 8, 5] After 1 pass: L1 = [9, 16, 1, 5, 8] After 2 passes: L1 = [9, 16, 1, 5, 8] What type of sort is being demonstrated and what will the list look like after the next (third) pass? a. Bubble sort, L1 = [9, 1, 5, 8, 16] b. Selection sort, L1 = [9, 1, 5, 8, 16] c. Selection sort, L1 = [16, 1, 5, 8, 9] d. Insertion sort, L1 = [9, 1, 5, 8, 16] e. Insertion sort, L1 = [16, 1, 5, 8, 9] Part (d) Here is a list and that list after each pass of a sort. Which sort is this? [5, 9, 0, 4, 6, 8, 2] [5, 9, 0, 4, 6, 8, 2] [0, 5, 9, 4, 6, 8, 2] [0, 4, 5, 9, 6, 8, 2] [0, 4, 5, 6, 9, 8, 2] [0, 4, 5, 6, 8, 9, 2] [0, 2, 4, 5, 6, 8, 9] a. Bubble sort b. Selection sort c. Insertion sort d. Merge sort Part (e) Consider the following list. How many swap operations are performed by selection sort, sorting in nondescending order? (If an item is already in the correct position, it is not swapped.) [9, 13, 6, 3, 1] a. 3 b. 4 c. 5 d. 8 e. 9 Page 13 of 20 Student #: cont d...
14 Question 6. [5 marks] What is the time complexity of each of the following pieces of code? Part (a) def mystery(l): index = 0 while 2 ** index < len(l): index += 1 Part (b) def mystery(l): index = 0 while index < len(l): index2 = 0 while index2 < index: index2 += 1 index +=1 Part (c) def mystery(l): index = 0 while index < 1000: index2 = 0 while index2 < len(l): index2 += 1 index +=1 Part (d) def mystery(l): index = 0 while index < 1000: index2 = 0 while index2 < index: index2 += 1 index +=1 Part (e) def mystery(l): index = 0 while index < len(l): index2 = 1 while index2 < len(l): index2 *= 2 index +=1 Page 14 of 20 cont d...
15 Question 7. [12 marks] class Character(object): # same as "class Character:" def init (self, name, game): self.name = name self.game = game def str (self): return "{0} from {1}".format(self.name, self.game) def repr (self): return "Character( {0}, {1} )".format(self.name, self.game) class Enemy(Character): def str (self): return "The Fearsome {0} from {1}".format(self.name, self.game) Part (a) [2 marks] What is displayed when these lines are entered on the console? >>> ch = Character("Link", "Zelda") >>> str(ch) >>> ch >>> ch = Enemy("Goomba", "SMB") >>> str(ch) >>> ch Part (b) [3 marks] Write a new class, Hero, that extends Character. Objects of the class should have an additional attribute, rating, which is set by the constructor. Page 15 of 20 Student #: cont d...
16 Part (c) [7 marks] Write a new class, Characters, that stores Character objects organized by the game they come from. Here is an example that shows what happens when your class is used: >>> chars = Characters() >>> chars.games() [] >>> chars.characters("zelda") [] >>> str(chars) >>> chars.add(character("link", "Zelda")) >>> chars.add(enemy("goomba", "SMB")) >>> chars.add(enemy("koopa", "SMB")) >>> chars.games() # The games may be in the list in any order [ SMB, Zelda ] >>> chars.characters("smb") # The characters may be in the list in any order [ Koopa, Goomba ] >>> str(chars) # The order of games and characters may vary SMB: The Fearsome Koopa from SMB The Fearsome Goomba from SMB Zelda: Link from Zelda Page 16 of 20 cont d...
17 [Space for previous question] Total Marks = 80 Page 17 of 20 Student #: cont d...
18 [Use the space below for rough work. This page will not be marked, unless you clearly indicate the part of your work that you want us to mark.] Page 18 of 20 cont d...
19 Short Python function/method descriptions: builtins : input([prompt]) -> str Read a string from standard input; return that string with no newline. The prompt string, if given, is printed without a trailing newline before reading. len(x) -> int Return the length of the list, tuple, dict, or string x. max(iterable) -> object max(a, b, c,...) -> object With a single iterable argument, return its largest item. With two or more arguments, return the largest argument. min(iterable) -> object min(a, b, c,...) -> object With a single iterable argument, return its smallest item. With two or more arguments, return the smallest argument. print(value,..., sep=, end= \n ) -> NoneType Prints the values. Optional keyword arguments: sep: string inserted between values, default space. end: string appended after the last value, default newline. open(name[, mode]) -> file Open a file. Legal modes are "r" (read), "w" (write), and "a" (append). range([start], stop, [step]) -> list-like-object of int Return the integers starting with start and ending with stop - 1 with step specifying the amount to increment (or decrement). If start is not specified, the list starts at 0. If step is not specified, the values are incremented by 1. dict: D[k] -> object Return the value associated with the key k in D. del D[k] Remove D[k] from D. k in d -> bool Return True if k is a key in D and False otherwise. D.get(k) -> object Return D[k] if k in D, otherwise return None. D.keys() -> list-like-object of object Return the keys of D. D.values() -> list-like-object of object Return the values associated with the keys of D. D.items() -> list-like-object of tuple of (object, object) Return the (key, value) pairs of D, as 2-tuples. file: F.close() -> NoneType Close the file. F.read() -> str Read and return all data until EOF (End Of File) is reached. F.readline() -> str Read and return the next line from the file. Retain newline. Return an empty string at EOF (End Of File). F.readlines() -> list of str Call readline() repeatedly and return a list of the lines so read until EOF (End Of File) is reached. Page 19 of 20 Student #: End of Final Examination
20 list: x in L -> bool Return True if x is in L and False otherwise. L.append(x) -> NoneType Append x to the end of L. L.index(value) -> int Return the lowest index of value in L. L.insert(index, x) -> NoneType Insert x at position index of L. L.pop() -> object Remove and return the last item from L. L.remove(value) -> NoneType Remove the first occurrence of value from L. L.reverse() -> NoneType Reverse L *IN PLACE*. L.sort() -> NoneType Sort L in ascending order *IN PLACE*. str: x in s -> bool Return True if x is in s and False otherwise. str(x) -> str Convert an object into its string representation, if possible. S.count(sub[, start[, end]]) -> int Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation. S.find(sub[, i]) -> int Return the lowest index in S (starting at S[i], if i is given) where the string sub is found or -1 if sub does not occur in S. S.index(sub) -> int Like find but raises an exception if sub does not occur in S. S.isdigit() -> bool Return True if all characters in S are digits and False otherwise. S.lower() -> str Return a copy of S converted to lowercase. S.lstrip([chars]) -> str Return a copy of S with leading whitespace removed. If chars is given and not None, remove characters in chars from s. S.replace(old, new) -> str Return a copy of S with all occurrences of the string old replaced with the string new. S.rstrip([chars]) -> str Return a copy of S with trailing whitespace removed. If chars is given and not None, remove characters in chars from s. S.split([sep]) -> list of str Return a list of the words in S; use string sep as the separator and any whitespace string if sep is not specified. S.strip() -> str Return a copy of S with leading and trailing whitespace removed. S.upper() -> str Return a copy of S converted to uppercase. Page 20 of 20 End of Final Examination
CSC148 Fall 2017 Ramp Up Session Reference
Short Python function/method descriptions: builtins : input([prompt]) -> str Read a string from standard input. The trailing newline is stripped. The prompt string, if given, is printed without a trailing
More informationPLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science DECEMBER 2013 EXAMINATIONS CSC 108 H1F Instructors: Craig and Gries Duration 3 hours PLEASE HAND IN Examination Aids: None Student Number:
More informationPLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science SUMMER 2012 EXAMINATIONS CSC 108 H1Y Instructors: Janicki Duration NA PLEASE HAND IN Examination Aids: None Student Number: Family Name(s):
More informationQuestion 1. Part (a) Part (b) December 2013 Final Examination Marking Scheme CSC 108 H1F. [13 marks] [4 marks] Consider this program:
Question 1. Part (a) [4 marks] Consider this program: [13 marks] def square(x): (number) -> number Write what this program prints, one line per box. There are more boxes than you need; leave unused ones
More informationPLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science APRIL 2012 EXAMINATIONS CSC 108 H1S Instructors: Campbell Duration 3 hours PLEASE HAND IN Examination Aids: None Student Number: Family
More informationPLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science APRIL 2010 EXAMINATIONS CSC 108 H1S Instructors: Horton Duration 3 hours PLEASE HAND IN Examination Aids: None Student Number: Family Name(s):
More informationPLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science DECEMBER 2009 EXAMINATIONS CSC 108 H1F Instructors: Gries, Horton, Zingaro Duration 3 hours PLEASE HAND IN Examination Aids: None Student
More informationStudent Number: Comments are not required except where indicated, although they may help us mark your answers.
CSC 108H5 F 2014 Midterm Test Duration 50 minutes Aids allowed: none Last Name: Student Number: First Name: Lecture Section: L0101 Instructor: Dan Zingaro (9:00-10:00) Lecture Section: L0102 Instructor:
More informationStudent Number: Comments are not required except where indicated, although they may help us mark your answers.
CSC 108H5 F 2018 Midterm Test Duration 90 minutes Aids allowed: none Student Number: utorid: Last Name: First Name: Do not turn this page until you have received the signal to start. (Please fill out the
More informationUNIVERSITY OF TORONTO SCARBOROUGH. December 2017 EXAMINATIONS. CSCA20H3 Duration 3 hours. Examination Aids: Instructor: Bretscher
PLEASE HAND IN UNIVERSITY OF TORONTO SCARBOROUGH December 2017 EXAMINATIONS CSCA20H3 Duration 3 hours PLEASE HAND IN Examination Aids: None Student Number: Last (Family) Name(s): First (Given) Name(s):
More informationUNIVERSITY OF TORONTO Faculty of Arts and Science APRIL 2014 EXAMINATIONS. CSC 108 H1S Instructors: Campbell and Papadopoulou.
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science APRIL 2014 EXAMINATIONS CSC 108 H1S Instructors: Campbell and Papadopoulou Duration 3 hours PLEASE HAND IN Examination Aids: None Student
More informationUNIVERSITY OF TORONTO SCARBOROUGH. Wnter 2016 EXAMINATIONS. CSC A20H Duration 2 hours 45 mins. No Aids Allowed
Student Number: Last Name: First Name: UNIVERSITY OF TORONTO SCARBOROUGH Wnter 2016 EXAMINATIONS CSC A20H Duration 2 hours 45 mins No Aids Allowed Do not turn this page until you have received the signal
More informationStudent Number: Instructor: Brian Harrington
CSC A08 2012 Midterm Test Duration 50 minutes Aids allowed: none Last Name: Student Number: First Name: Instructor: Brian Harrington Do not turn this page until you have received the signal to start. (Please
More informationPLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science APRIL 2016 EXAMINATIONS CSC 108 H1S Instructor(s): Smith and Fairgrieve Duration 3 hours PLEASE HAND IN No Aids Allowed You must earn at
More informationQuestion 1. December 2009 Final Examination Marking Scheme CSC 108 H1F
Question 1. [10 marks] Below are five segments of code. Each one runs without error. To the right of each segment, show the output it generates. L = [1, 2, 3, 4] for item in L: item = item * 5 print L
More informationPLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science APRIL 2015 EXAMINATIONS CSC 108 H1S Instructor: Fairgrieve and Hagerman Duration 3 hours PLEASE HAND IN Examination Aids: None You must
More informationUTORid: Lecture Section: (circle one): L0101 (MWF10) L0201 (MWF11) Instructor: Jacqueline Smith Jen Campbell
CSC 108H1 F 2017 Midterm Test Duration 50 minutes Aids allowed: none Last Name: UTORid: First Name: Lecture Section: (circle one): L0101 (MWF10) L0201 (MWF11) Instructor: Jacqueline Smith Jen Campbell
More informationPLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science DECEMBER 2016 EXAMINATIONS CSC 108 H1F Instructor(s): Smith, Gries, de Lara Duration 3 hours PLEASE HAND IN No Aids Allowed You must earn
More informationUNIVERSITY OF TORONTO Faculty of Arts and Science DECEMBER 2017 EXAMINATIONS. CSC 108 H1F Instructor(s): Campbell, Fairgrieve, and Smith
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science DECEMBER 2017 EXAMINATIONS CSC 108 H1F Instructor(s): Campbell, Fairgrieve, and Smith Duration 3 hours PLEASE HAND IN No Aids Allowed You
More informationDo not turn this page until you have received the signal to start.
CSCA08 Fall 2014 Final Exam Duration 160 minutes Aids allowed: none Student Number: A Instructor: Brian Harrington Last Name: First Name: UtorID (Markus Login): Do not turn this page until you have received
More informationDo not turn this page until you have received the signal to start.
CSCA48 Fall 2015 Final Exam Duration 150 minutes Aids allowed: none Student Number: Instructor: Brian Harrington and Anna Bretscher Last Name: First Name: UtorID (Markus Login): Do not turn this page until
More informationPLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
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)
More informationCSC A20H3 S 2011 Test 1 Duration 90 minutes Aids allowed: none. Student Number:
CSC A20H3 S 2011 Test 1 Duration 90 minutes Aids allowed: none Last Name: Lecture Section: L0101 Student Number: First Name: Instructor: Bretscher Do not turn this page until you have received the signal
More informationShort Python function/method descriptions:
Last Name First Name Student#. Short Python function/method descriptions: builtins : len(x) -> integer Return the length of the list, tuple, dict, or string x. max(l) -> value Return the largest value
More informationQuestion 1. Part (a) Part (b) Part (c) April 2015 Final Examination Solutions CSC 108 H1S. [16 marks] [3 marks]
Question 1. Part (a) [3 marks] [16 marks] Consider this Python code: L = [8, 12, 3] X = L.sort() Y = L[:] L.extend([1]) Write what this code prints when run, with one line per box. There may be more boxes
More informationDo not turn this page until you have received the signal to start.
CSCA08 Fall 2015 Term Test #2 Duration 110 minutes Aids allowed: none Last Name: Student Number: Markus Login: First Name: Please place a checkmark ( ) beside your tutorial session Tutorial Number Date/Time
More informationShort Python function/method descriptions:
Last Name First Name Student#. Short Python function/method descriptions: builtins : len(x) -> integer Return the length of the list, tuple, dict, or string x. max(l) -> value Return the largest value
More informationDo not turn this page until you have received the signal to start.
CSCA48 Winter 2015 Midterm Exam Duration 100 minutes Aids allowed: none Student Number: Instructors: Anna Bretscher & Brian Harrington Last Name: First Name: UtorID (Markus Login): Please place a checkmark
More informationGood Luck! CSC207, Fall 2012: Quiz 1 Duration 25 minutes Aids allowed: none. Student Number:
CSC207, Fall 2012: Quiz 1 Duration 25 minutes Aids allowed: none Student Number: Last Name: Lecture Section: L0101 First Name: Instructor: Horton Please fill out the identification section above as well
More informationPlease note, you CANNOT petition to re-write an examination once the exam has begun.
NAME (PRINT): STUDENT #: Last/Surname First /Given Name SIGNATURE: UNIVERSITY OF TORONTO MISSISSAUGA DECEMBER 2013 FINAL EXAMINATION CSC324H5F Principles of Programming Languages Anthony Bonner Duration
More informationPLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science AUGUST EXAMINATIONS CSC 108H1Y Instructor: Daniel Zingaro Duration three hours PLEASE HAND IN Examination Aids: None. Student Number: Last
More informationCSC 108H1 F 2009 Test 1 Duration 35 minutes Aids allowed: none. Student Number:
CSC 108H1 F 2009 Test 1 Duration 35 minutes Aids allowed: none Last Name: Student Number: First Name: Lecture Section: L0102 Instructor: Gries Do not turn this page until you have received the signal to
More informationDo not turn this page until you have received the signal to start. In the meantime, please read the instructions below carefully.
CSC 148 H1 / L0101 Term Test # 2 13 March 2013 Duration: Aids Allowed: 50 minutes None Student Number: Last (Family) Name(s): First (Given) Name(s): Do not turn this page until you have received the signal
More informationChapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More informationGood Luck! Marking Guide. APRIL 2014 Final Exam CSC 209H5S
APRIL 2014 Final Exam CSC 209H5S Last Name: Student #: First Name: Signature: UNIVERSITY OF TORONTO MISSISSAUGA APRIL 2014 FINAL EXAMINATION CSC209H5S System Programming Daniel Zingaro Duration - 3 hours
More informationStrings are actually 'objects' Strings
Strings are actually 'objects' Strings What is an object?! An object is a concept that we can encapsulate data along with the functions that might need to access or manipulate that data. What is an object?!
More informationCIS192: Python Programming Data Types & Comprehensions Harry Smith University of Pennsylvania September 6, 2017 Harry Smith (University of Pennsylvani
CIS192: Python Programming Data Types & Comprehensions Harry Smith University of Pennsylvania September 6, 2017 Harry Smith (University of Pennsylvania) CIS 192 Fall Lecture 2 September 6, 2017 1 / 34
More informationUNIVERSITY OF TORONTO SCARBOROUGH. Fall 2015 EXAMINATIONS. CSC A20H Duration 3 hours. No Aids Allowed
Student Number: Last Name: First Name: UNIVERSITY OF TORONTO SCARBOROUGH Fall 2015 EXAMINATIONS CSC A20H Duration 3 hours No Aids Allowed Do not turn this page until you have received the signal to start.
More informationCIS192 Python Programming
CIS192 Python Programming Data Types Joseph Cappadona University of Pennsylvania September 03, 2015 Joseph Cappadona (University of Pennsylvania) CIS 192 September 03, 2015 1 / 32 Outline 1 Data Types
More informationUNIVERSITY OF TORONTO Faculty of Arts and Science
UNIVERSITY OF TORONTO Faculty of Arts and Science Midterm 2 s CSC148H1F Duration: 50 min. Instructors: Diane Horton, David Liu. Examination Aids: Provided aid sheet Name: Student Number: Please read the
More information>>> print( X ) [0,1,2,3] def mystery(l):??
REVIEW EXERCISES Problem 4 What is the output of the following script? Disclaimer. I cannot guarantee that the exercises of the final exam are going to look like this. Also, for the most part, the exercises
More informationPython allows variables to hold string values, just like any other type (Boolean, int, float). So, the following assignment statements are valid:
1 STRINGS Objectives: How text data is internally represented as a string Accessing individual characters by a positive or negative index String slices Operations on strings: concatenation, comparison,
More informationLecture no
Advanced Algorithms and Computational Models (module A) Lecture no. 3 29-09-2014 Giacomo Fiumara giacomo.fiumara@unime.it 2014-2015 1 / 28 Expressions, Operators and Precedence Sequence Operators The following
More informationCS 2316 Exam 1 Spring 2014
CS 2316 Exam 1 Spring 2014 Name : Grading TA: Integrity: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking of this exam
More informationCPD for GCSE Computing: Practical Sheet 6 February 14
Aims Programming Sheet 6 Arrays in Python Section Aim 1 Arrays A variable with many values Understand the idea of an array as a way to combine many values that are assigned to as single variable. 2 While
More informationCS 1110 Prelim 2 November 14th, 2013
CS 1110 Prelim 2 November 14th, 2013 This 90-minute exam has 6 questions worth a total of 100 points. Scan the whole test before starting. Budget your time wisely. Use the back of the pages if you need
More informationQuestion 1. Part (a) Simple Syntax [1 mark] Circle add_ints(), because it is missing arguments to the function call. Part (b) Simple Syntax [1 mark]
Note to Students: This file contains sample solutions to the term test together with the marking scheme and comments for each question. Please read the solutions and the marking schemes and comments carefully.
More informationPLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science AUGUST 2011 EXAMINATIONS CSC 209H1Y Instructor: Daniel Zingaro Duration three hours PLEASE HAND IN Examination Aids: one two-sided 8.5x11
More informationCS 1110 Prelim 1, March 2018
Last Name: First Name: Cornell NetID, all caps: CS 1110 Prelim 1, March 2018 This 90-minute exam has 7 questions worth a total of 69 points. You may separate the pages while working on the exam; we have
More informationCSC148 Recipe for Designing Classes
Part 1: Define the API for the class CSC148 Recipe for Designing Classes Download the sample code here: https://www.teach.cs.toronto.edu/~csc148h/fall/lectures/object-oriented-programming/common/course.
More informationPython Programming: Lecture 2 Data Types
Python Programming: Lecture 2 Data Types Lili Dworkin University of Pennsylvania Last Week s Quiz 1..pyc files contain byte code 2. The type of math.sqrt(9)/3 is float 3. The type of isinstance(5.5, float)
More informationCSC 108H1 F 2010 Test 1 Duration 45 minutes Aids allowed: none. Student Number:
CSC 108H1 F 2010 Test 1 Duration 45 minutes Aids allowed: none Last Name: Lecture Section: L0101 Student Number: First Name: Instructors: Horton and Engels Do not turn this page until you have received
More informationYou may not share any information or materials with classmates during the exam and you may not use any electronic devices.
ICS 31 UC IRVINE WINTER 2014 DAVID G. KAY Second Midterm YOUR NAME YOUR LAB: YOUR STUDENT ID (8 DIGITS) SECTION (1 TO 9) ******************** YOUR UCINET ID TIME MWF AT: 8 10 12 2 4 6 ****** K E Y ******
More informationSequences and iteration in Python
GC3: Grid Computing Competence Center Sequences and iteration in Python GC3: Grid Computing Competence Center, University of Zurich Sep. 11 12, 2013 Sequences Python provides a few built-in sequence classes:
More informationCS 1110 Final, December 8th, Question Points Score Total: 100
CS 1110 Final, December 8th, 2016 This 150-minute exam has 8 questions worth a total of 100 points. Scan the whole test before starting. Budget your time wisely. Use the back of the pages if you need more
More informationPython: Short Overview and Recap
Python: Short Overview and Recap Benjamin Roth CIS LMU Benjamin Roth (CIS LMU) Python: Short Overview and Recap 1 / 39 Data Types Object type Example creation Numbers (int, float) 123, 3.14 Strings this
More information\n is used in a string to indicate the newline character. An expression produces data. The simplest expression
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More informationBabu Madhav Institute of Information Technology, UTU 2015
Five years Integrated M.Sc.(IT)(Semester 5) Question Bank 060010502:Programming in Python Unit-1:Introduction To Python Q-1 Answer the following Questions in short. 1. Which operator is used for slicing?
More informationCS 1110 Final, May 2017
Last Name: First Name: Cornell NetID, all caps: CS 1110 Final, May 2017 This 150-minute exam has 9 questions worth a total of 117 points. You may separate the pages while working on the exam; we have a
More informationAdvanced Python. Executive Summary, Session 1
Advanced Python Executive Summary, Session 1 OBJECT: a unit of data of a particular type with characteristic functionality (i.e., methods and/or use with operators). Everything in Python is an object.
More information1 Fall 2017 CS 1110/1111 Exam 3
1 Fall 2017 CS 1110/1111 Exam 3 Bubble in your computing ID in the footer of this page. We use an optical scanner to read it, so fill in the bubbles darkly. If you have a shorter ID, leave some rows blank.
More informationCS 1110 Final, December 8th, Question Points Score Total: 100
CS 1110 Final, December 8th, 2016 This 150-minute exam has 8 questions worth a total of 100 points. Scan the whole test before starting. Budget your time wisely. Use the back of the pages if you need more
More informationCS 1301 Exam 1 Fall 2010
CS 1301 Exam 1 Fall 2010 Name : Grading TA: Integrity: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking of this exam in
More informationUNIVERSITY OF TORONTO Faculty of Arts and Science. Midterm 1 CSC148H1F L0201 (Liu)
UNIVERSITY OF TORONTO Faculty of Arts and Science Midterm 1 CSC148H1F L0201 (Liu) October 21, 2016 (50 min.) Examination Aids: Provided aid sheet (back page, detachable!) Name: Student Number: Please read
More informationOverview of List Syntax
Lists and Sequences Overview of List Syntax x = [0, 0, 0, 0] Create list of length 4 with all zeroes x 4300112 x.append(2) 3 in x x[2] = 5 x[0] = 4 k = 3 Append 2 to end of list x (now length 5) Evaluates
More informationICS 31 UC IRVINE. ############## YOUR UCINET #### K E Y #### ############## Second Midterm YOUR NAME YOUR STUDENT ID (8 DIGITS)
ICS 31 UC IRVINE SPRING 2017 DAVID G. KAY YOUR NAME YOUR STUDENT ID (8 DIGITS) ############## YOUR UCINET ID @UCI.EDU #### K E Y #### ############## Second Midterm You have 75 minutes (until the end of
More informationCS111 Jeopardy: The Home Version
CS111 Jeopardy: The Home Version The game that turns CS111 into CSfun11! Fall 2018 This is intended to be a fun way to review some of the topics that will be on the CS111 final exam. These questions are
More informationFinal Exam(sample), Fall, 2014
Final Exam(sample), Fall, 2014 Date: Dec 4 th, 2014 Time: 1.25 hours (1.00 a.m. 2:15 p.m.) Total: 100 points + 20 bonus Problem 1 T/F 2 Choice 3 Output Points 16 16 48 4 Programming 20 5 Bonus 20 Total
More informationPart III Appendices 165
Part III Appendices 165 Appendix A Technical Instructions Learning Outcomes This material will help you learn how to use the software you need to do your work in this course. You won t be tested on it.
More informationQuestion 0. Do not turn this page until you have received the signal to start.
CSCA48 Winter 2017 Final Exam Duration 2 hours 50min Aids allowed: none Last Name: Student Number: Markus Login: First Name: A Question 0. [1 mark] Carefully read and follow all instructions on this page,
More informationPLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science APRIL 2017 EXAMINATIONS CSC 104 H1S Instructor(s): G. Baumgartner Duration 3 hours PLEASE HAND IN No Aids Allowed Student Number: Last (Family)
More informationDo not turn this page until you have received the signal to start. In the meantime, please read the instructions below carefully.
CSC A48 Winter 2014 CSCA48 Final Exam 23 April 2014 Duration: Aids Allowed: 150 minutes None Student Number: UTORid: Last (Family) Name(s): First (Given) Name(s): Do not turn this page until you have received
More informationQuestion 1. CSC 148H1 Term test #1 Solutions February [8 marks]
Question 1. [8 marks] Suppose we are creating a program for online opinion polls. We need a class called PollQuestion, which records information about a single question on an opinion poll, including the
More informationCS 1110 Prelim 1 October 15th, 2015
CS 1110 Prelim 1 October 15th, 2015 This 90-minute exam has 6 uestions worth a total of 100 points. Scan the whole test before starting. Budget your time wisely. Use the back of the pages if you need more
More informationPython Mini Lessons last update: May 29, 2018
Python Mini Lessons last update: May 29, 2018 From http://www.onlineprogramminglessons.com These Python mini lessons will teach you all the Python Programming statements you need to know, so you can write
More informationCIS192 Python Programming
CIS192 Python Programming Iterators, Generators, Exceptions & IO Raymond Yin University of Pennsylvania September 28, 2016 Raymond Yin (University of Pennsylvania) CIS 192 September 28, 2016 1 / 26 Outline
More informationCS 1301 Exam 1 Fall 2010
CS 1301 Exam 1 Fall 2010 Name : Grading TA: Integrity: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking of this exam in
More informationCIS192 Python Programming
CIS192 Python Programming Object Oriented Programming Harry Smith University of Pennsylvania February 15, 2016 Harry Smith (University of Pennsylvania) CIS 192 Lecture 5 February 15, 2016 1 / 26 Outline
More informationList Mutation (Module 4) Accumulative Recursion (Module 5) Efficiency (Module 7) Searching & Sorting (Module 8) Dictionaries (Module 9)
Sherry & Pauline List Mutation (Module 4) Review for CS 116!!! Accumulative Recursion (Module 5) Efficiency (Module 7) Searching & Sorting (Module 8) Dictionaries (Module 9) Class Objects (Module 9) Files
More informationSpring Semester 11 Exam #1 Dr. Dillon. (02/15)
Spring Semester 11 Exam #1 Dr. Dillon. (02/15) Form 1 A Last name (printed): First name (printed): Directions: a) DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN. b) You may use one 8.5"
More informationSequence Types FEB
Sequence Types FEB 23-25 2015 What we have not learned so far How to store, organize, and access large amounts of data? Examples: Read a sequence of million numbers and output these in sorted order. Read
More informationCS 1110 Final, December 17th, Question Points Score Total: 100
CS 1110 Final, December 17th, 2014 This 150-minute exam has 8 questions worth a total of 100 points. Scan the whole test before starting. Budget your time wisely. Use the back of the pages if you need
More informationQuestion 1. Part (a) Functions [2 marks] def make_a_wish(): print("happy Halloween") make_a_wish() Part (b) Loops and Lists [3 marks]
Question 1. [9 marks] Treat each subquestion independently (i.e., code in one question is not related to code in another), and answer each question in the space provided. Part (a) Functions [2 marks] Write
More informationCIS192 Python Programming
CIS192 Python Programming Generators Exceptions and IO Eric Kutschera University of Pennsylvania February 13, 2015 Eric Kutschera (University of Pennsylvania) CIS 192 February 13, 2015 1 / 24 Outline 1
More informationSpring 2017 CS 1110/1111 Exam 1
CS 1110/1111 Spring 2017 Exam 1 page 1 of 6 Spring 2017 CS 1110/1111 Exam 1 Bubble in your computing ID in the footer of this page. We use an optical scanner to read it, so fill in the bubbles darkly.
More informationECE 364 Software Engineering Tools Laboratory. Lecture 4 Python: Collections I
ECE 364 Software Engineering Tools Laboratory Lecture 4 Python: Collections I 1 Lecture Summary Lists Tuples Sets Dictionaries Printing, More I/O Bitwise Operations 2 Lists list is a built-in Python data
More informationQuestion 1. CSC 120H1 F Midterm Test Solutions Fall 2017
Question 1. [5 marks] Fill in the boxes below with what you would see in your Python shell if you were to type the following expressions. If that code would result in an error, then write ERROR and provide
More informationCIS192 Python Programming
CIS192 Python Programming Iterators, Generators, IO, and Exceptions Harry Smith University of Pennsylvania February 15, 2018 Harry Smith (University of Pennsylvania) CIS 192 Lecture 5 February 15, 2018
More informationIntroduction to Python! Lecture 2
.. Introduction to Python Lecture 2 Summary Summary: Lists Sets Tuples Variables while loop for loop Functions Names and values Passing parameters to functions Lists Characteristics of the Python lists
More informationAbout the Final. Saturday, 7-10pm in Science Center 101. Closed book, closed notes. Not on the final: graphics, file I/O, vim, unix
CS 21 Final Review About the Final Saturday, 7-10pm in Science Center 101 Closed book, closed notes Not on the final: graphics, file I/O, vim, unix Expect Questions That Ask You To: Evaluate Python expressions
More informationBasic Scripting, Syntax, and Data Types in Python. Mteor 227 Fall 2017
Basic Scripting, Syntax, and Data Types in Python Mteor 227 Fall 2017 Basic Shell Scripting/Programming with Python Shell: a user interface for access to an operating system s services. The outer layer
More informationUNIVERSITY OF TORONTO Faculty of Arts and Science
UNIVERSITY OF TORONTO Faculty of Arts and Science Midterm 1 s CSC148H1F Duration: 50 min. Instructors: Diane Horton, David Liu. Examination Aids: Provided aid sheet Name: Student Number: Please read the
More informationMidterm Exam 2B Answer key
Midterm Exam 2B Answer key 15110 Principles of Computing Fall 2015 April 6, 2015 Name: Andrew ID: Lab section: Instructions Answer each question neatly in the space provided. There are 6 questions totaling
More informationCS150 Sample Final. Name: Section: A / B
CS150 Sample Final Name: Section: A / B Date: Start time: End time: Honor Code: Signature: This exam is closed book, closed notes, closed computer, closed calculator, etc. You may only use (1) the final
More informationYou may not share any information or materials with classmates during the exam and you may not use any electronic devices.
ICS 31 UC IRVINE FALL 2012 DAVID G. KAY YOUR NAME YOUR LAB: YOUR STUDENT ID (8 DIGITS) SECTION (1-10) YOUR UCINET ID TIME MWF AT: 8 10 12 2 4 6 TA S NAME Second Midterm You have 75 minutes (until the end
More informationUniversity of Washington CSE 140 Data Programming Winter Final exam. March 11, 2013
University of Washington CSE 140 Data Programming Winter 2013 Final exam March 11, 2013 Name: Section: UW Net ID (username): This exam is closed book, closed notes. You have 50 minutes to complete it.
More informationIntroduction to Computer Programming for Non-Majors
Introduction to Computer Programming for Non-Majors CSC 2301, Fall 2015 Chapter 5 Part 1 The Department of Computer Science Objectives To understand the string data type and how strings are represented
More informationCIS 110 Introduction to Computer Programming Summer 2018 Final. Recitation # (e.g., 201):
CIS 110 Introduction to Computer Programming Summer 2018 Final Name: Recitation # (e.g., 201): Pennkey (e.g., paulmcb): My signature below certifies that I have complied with the University of Pennsylvania
More informationCS2304: Python for Java Programmers. CS2304: Sequences and Collections
CS2304: Sequences and Collections Sequences In Python A sequence type in python supports: The in membership operator. The len() function. Slicing like we saw with strings, s[1:3]. And is iterable (for
More informationStrings. Upsorn Praphamontripong. Note: for reference when we practice loop. We ll discuss Strings in detail after Spring break
Note: for reference when we practice loop. We ll discuss Strings in detail after Spring break Strings Upsorn Praphamontripong CS 1111 Introduction to Programming Spring 2018 Strings Sequence of characters
More information