Mod1-Mod2
Mod3-Mod4
Mod5-Mod6
Mod7-Mod8
Mod9-Mod10
100

print(list(range(1,5)))

[1, 2, 3, 4]

  

100

What is the import statement for:
x = random.randrange(5)


import random

100

list(range(10, 12, -2))

[]

100

In an UML diagram how do you indicate Containment (Aggregation).

diamond

100

When other is used as a parameter, it commonly refers to what is on the right hand side of the operator. (True/False)

True

200

What parameters would you use for range to simulate all the numbers that are on a standard 6-sided dice?

(1,7)

200

How do you create a turtle object named tess?

tess = Turtle()

200

What code allows the programmer to handle an exception so that python doesn't crash?

try except

200

Which method do you call when you use constructor chaining and how do you do it?

super().__init__

The parents constructor

200

What does polymorphism mean?

many shapes

300

print(list(range(3,9,3)))

[3, 6]

 

300

What is the constructor method called in python?

__init__

300

What is the difference between an alias and a clone?

Alias ->Multiple variables that contain references to the same object. 

Clone->To create a new object that has the same value as an existing object. 

300

Give an 3 examples of inheritance (parent<-child) from frogger and/or asteroids.

Movable<-Rotatable<-Polygon<-Ship

etc.

300

What is duck typing? Give an example from Assignments this semester.

If all of the operations inside the function can be applied to the type, the function can be applied to the type. 

hits(), evolveAllObjects, evolve, draw, etc.

400

longer_list = [1,2]
longer_list = longer_list.append(3)
print(longer_list) 

None

400

Modularity is the ability to take code, encapsulate it so it can be used it in other places. Give 3 advantages to modularity.

1. code reuse

2. code testing

3. code maintainability.

400

What is the quickest way to find semantic errors? The long way is to step through the debugger.

Use print statements

400

What is deep copy?

To copy the contents of an object as well as any embedded objects, and any objects embedded in them, and so on

400

In operator overloading, give an example of a method that is required to return self.

__iadd__, __imul__, +=, *=

500

color_tuple = (183,27,27) #red
color_tuple[1] = 183 # add more to green
print(color_tuple)

TypeError

500

What is Built-in scope? Give an example.

refers to all the identifiers built into Python(ex: range, sum, min, max)

500

Create a copy of a_list called b_list

b_list = a_list[:]

500

I1 = Inventory(3)
b = Bicycle(7,25)
I1.add_bike(b)
I2 = deepcopy(I1)

How many bicycle objects will be stored in memory after this code is run?

2

500

Why would we have the __add__ method call __iadd__?

All of the math is done in __iadd__ so it can all be updated/fixed in one place.