Python Homework Help
Python Homework Help
Eric.withdraw(3000.0)
Ellen.withdraw(3000.0)
3000.0
3000.0
Eric.value Ellen.value
850.0 970.0
Eric.withdraw(1000.0) Ellen.withdraw(1000.0)
800.0 960.0
Ellen.value
Eric.value
0.0
0
Eric.deposit(5000.0) Ellen.deposit(5000.0)
None None
Eric.value Ellen.value
4750.0 5000.0
2 So who kicks b***
class League:
def __init__(self):
self.teams = {}
def addTeam(self, team):
self.teams[team.name] = team
def updateGame(self, teamName, ptsFor,
ptsAgin):
# to be filled in
def computeStat(self, proc, filt):
return [proc(team) for team in
self.teams.values() if filt(team)]
Assume that the NFL has been defined as above, but with more
teams. Write an expression using computeStat, to be evaluated by
the Python interpreter, that will return a list of wins for all teams
in the NFL. (It is okay to define and use helper functions.) For
the example instance defined above, your expression should
return the list:
[5, 4, 1]
For each difference equation below, say whether, for a unit sample
input signal:
diverge? Yes or No No
positive/alternate/oscillate Alternate
Part 2:
Why?
pole is
complex
Then
Po[n] = 2Po[n − 1] − 0.5Po[n − 2]
Suppose that Po[0] = 10 and Po[n] = 0 if n < 0. What are the first
few values for the number of cells (note that while not physically
realistic, our model might provide fractional answers)?
Po[0] = 10
Po[1] = 20
Po[2] = 35
Po[3] = 60
Circle all of the classes that satify this relation, or circle none if
none satisfy it.
GrowthA GrowthB GrowthC G rowthD no
GrowthD
GrowthB
Part c. Let HA, HB, HC, and HD represent the system functions
associated with the state machines generated by GrowthA,
GrowthB, GrowthC, and GrowthD, respectively. Fill in the
following Part Midterm 1 Solutions — Fall 10 11 b. Determine
which (if any) of GrowthA, GrowthB, GrowthC, and GrowthD
generate state machines whose input-output relation can be
expressed as the following block diagram. Delay Delay 1 2 X Y +
Circle all of the classes that satify this relation, or circle none if
none satisfy it. table to indicate the number and locations of the
poles of HA, HB, HC, and HD. Pole locations can be listed in any
order. Leave unnecessary entries blank.
2, 1 + root(2), 1 - root(2)
2, 2, -1
0
0
>>>v = Vending()
>>>v.transduce([1,1,1])
[None, None, ’jolt’]
>>>v.transduce([1,2])
[None, ’jolt’]
>>>v.transduce([5,1,4,2])
[5, None, 4, ’jolt’]
class Vending(sm.SM):
startState = None
def getNextValues(self, state,
inp):