Python Homework Help
Python Homework Help
test.take(2) test.take(2)
Error
3
test.give(6) test.give(6)
11
(0, 3)
test.howmuch() test.howmuch()
class Student:
def __init__(self, name, iq,
salary, height):
self.name = name
self.iq = iq
self.salary = salary
self.height = height
class StudentBody:
def __init__(self):
self.students = []
def addStudent(self, student):
self.students.append(student)
def nameOfSmartest(self):
# code will go here
def funOfBest(self, fun, feature):
# code will go here
The StudentBody class is missing the code for two
methods:
• nameOfSmartest: returns the name attribute of the student with
the highest IQ
For the first two problems below, assume that these methods have
been implemented.
Here is a student body:
pythonhomeworkhelp.com
1. What is the result of evaluating
aardvarkU.nameOfSmartest()?
’Chris’
def nameOfSmartest(self):
return util.argmax(self.students,
lambda x: x.iq).name
# or
def nameOfSmartest(self):
return funOfBest(lambda x: x.name,
lambda x: x.iq)
class Student:
def __init__(self, name, iq, salary,
height):
self.name = name
self.iq = iq
self.salary = salary
self.height = height
class StudentBody:
def __init__(self):
self.students = []
def addStudent(self,
student):
self.student.append(student)
def deleteStudent(self, student):
self.students.remove(student)
def nameOfSmartest(self):
pass def funOfBest(self, fun,
feature):
pass
3 SM to DE
Thing().transduce([1, 2, 0, 1, 3])
[0, 0, 3, 6, 6]
4 Diagnosis
class M1(SM):
startState = 0
def getNextValues(self,
state, inp):
return inp + state
Should return tuple of new state and output
2.
class M2(SM):
startState = 0
def getNextValues(self,
state, inp):
return (inp+state, (state,
state))
This is fine
3.
class M3(SM):
def __init__(self):
self.startState = [1, 2, 3]
def getNextValues(self, state, inp):
state.append(inp)
result = sum(state) /
float(len(state))
return (result, state
4.
class M4(SM):
startState = -1
def __init__(self, v):
self.value = v
def
getNextValues(self, state, inp):
if state > inp:
self.value = self.value +
state
result = self.value * 2
return (state, result)
5 Picture to Machine
FeedbackSubtract(Cascade(Cascade(Gain(k1), R()),
FeedbackSubtract(Gain(k2),
Cascade(R(),R()))),
R())
6 On the Verge
1.
diverge? Yes or No No
positive/alternate/oscillate Positive
2.
7 What’s Cooking?
2. Let the system start at rest (all signals are zero). Suppose I[0]
= 100 and I[n] = 0 for n > 0. Here are plots of T[n] as a function
of n for this system for c = 1 and different values of k1 and k2.
a. Which of the plots above corresponds to k1 = 0.5
and k2 = 0 ?