You are on page 1of 13

CS 1301 Exam 3 - Version 1 (Yellow)

Youngjoon Lim
TOTAL POINTS

91 / 100

QUESTION 1 Part II - Big-O Notation, Sorting and


Part I - Using An API 16 pts Searching 30 pts
1.1 1.1: What is an API? 4 / 4 2.1 2.1: Function A vs Function B 3 / 3
+ 4 Correct + 3 Correct - A is faster because dictionary lookup is
+ 1 What API stands for is correct (Application faster than looping through a list
programming interface) + 2 Answer says A is faster, but the reason is
+ 3 Correct explanation of what an API is used for and incorrect
how it is beneficial: With an API a company can make + 0 Incorrect
its data available and easy for developers to use to 2.2 2.2: What is the function doing? 5 / 5
create their own projects. + 5 Correct
+ 0 Incorrect + 1 The code searches a list for a key
1.2 1.2: API Example 4 / 4 + 2 It returns the place in the list where the key was
+ 4 Valid example of an api that could be made found (the index)
- 1 Not specific + 1 if the key is not found it returns None
- 2 Missing endpoints + 1 O(n)
+ 0 Incorrect + 0 Incorrect
1.3 1.3: What is the requests module? 3 / 4 2.3 2.3a: 4 / 4
+ 4 Correct + 4 1, 3, 5, 7, 8
+ 2 [2 pts] Requests allows you to send a request to + 0 Incorrect
an API to get info. 2.4 2.3b: 4 / 4
+ 1 Mentions getting information from a website + 4 Correct - 7, 10, 8
(instead of API) + 0 Incorrect
+ 2 [2 pts] get() 2.5 2.3c: 2 / 3
+ 0 Incorrect + 3 Correct - It is much faster because at worst case
1.4 1.4: What is JSON? 4 / 4 you do not have to examine all the elements.
+ 4 Correct (optional - only log n of the elements)
+ 2 [2 pts] Because APIs return their information as a + 2 Answer mentions speed or Big-O difference
string, using JSON as a standard for formatting the without reasoning
information in the string makes it easy for python + 0 Incorrect
code to be able to interpret the information. 2.6 2.3d: 3 / 3
+ 2 [2 pts] You receive the JSON data when you send + 3 Correct - list must be sorted
a get request to an API. + 0 Incorrect
+ 0 Incorrect
2.7 2.4: mysterySort 4 / 8
QUESTION 2 + 2 [54, 93, 26]
+ 2 [26, 54, 93] + 1 Mercedes
+ 2 Insertion Sort + 0 Incorrect
+ 2 O(n^2) - 1 quotes
+ 0 Incorrect - 1 Not exact
- 1 Extra lines - 1 Extra Lines
4.2 4.2a 4 / 4
QUESTION 3
+ 4 Correct: Spike is 3 years old! (Or 28 dog years!)
Part III: Exception Handling 12 pts +23
3.1 3.1a: 4 / 4 + 2 28
+ 4 Correct - 9 \n 0 \n done + 0 Incorrect
+ 1 First line is 9 - 1 Quotations
+ 2 Second line is 0 4.3 4.2b: 4 / 4
+ 1 Third line is done + 4 Correct
+ 0 Incorrect + 1 Makes a list of puppies
- 1 Quotations on done + 1 List has 100 puppies of 100 ages
- 1 Extra line + 1 Appends a puppy to the list at some point
3.2 3.1b: 4 / 4 + 1 Calls the puppy constructor
+ 4 Correct - -4 \n 10 \n 9 + 0 Incorrect
+ 1 First line is -4 - 0.5 Syntax error
+ 2 Second line is 10 4.4 4.2c: 3 / 4
+ 1 Third line is 9 + 4 Completely correct
+ 0 Incorrect + 0 Incorrect
- 1 Any additional lines + 1 Creates a variable set to zero
3.3 3.1c: 4 / 4 + 1 Iterates through puppy list
+ 4 Correct - 1 \n 2 \n 3 \n 3 + 1 Increments variable by puppy.age for each
+ 1 First line is 1 iteration
+ 1 Second line is 2 + 1 Correctly finds the average
+ 1 Third line is 3 - 0.5 Did not print average
+ 1 Last line is 3 - 0.5 Syntax Error
- 1 Any additional lines 4.5 4.3a: 4 / 4
+ 0 Incorrect + 4 Correct - Milhouse [1 pt] friends are: 1. [1 pt]
Homer [1 pt] 2. Lisa [1 pt]
QUESTION 4
+ 1 Milhouse
Part IV: Object Oriented Programming 42 + 1 Homer
pts
+ 1 Lisa
4.1 4.1a 4 / 4 + 1 friends are: 1. and 2. (intermediary words)
+ 4 Correct: Im driving a Audi Mercedes, bro. \n Im + 0 Incorrect
driving a blue Mercedes, bro. - 1 any additional lines
+ 1 Im driving a Audi
4.6 4.3b: 2 / 2
+ 1 Mercedes
+ 2 All Correct - 2 attributes, 3 methods
+ 1 Im driving a blue
+ 1 Correct - 2 attributes
+ 1 Correct - 3 methods
+ 0 Incorrect
4.7 4.4: 18 / 20
+ 20 Correct
+ 1 class Employee:
+ 4 correct __init__ method
+ 4 correct incrementhours method
+ 4 correct paycheck method
+ 4 correct __str__ method
+ 3 correct __eq__method
+ 1 header correct in __eq__ method but body of
method missing or incorrect
- 1 return instead of print (or vice versa) error
- 1 syntax error
- 1 did not cast ints to str when needed
- 1 unnecessary return statement in incrementhours
- 1 didn't account for self.name in __str__
+ 0 Incorrect
- 1 Missing self
- 1 missing return or missing print statement
- 2 Two additional missing return or print statements

Page 3

You might also like