6 views

Uploaded by api-127299018

- Technical Reference Manual - RAPID Instructions, Functions and Data Type
- The Ring programming language version 1.5.1 book - Part 19 of 180
- f90
- EN234FEA Tutorial 2017
- 00 L CPU Syslib-rm017 -En-e
- messagebroker_ESQL v6.0
- SUB program
- 02 Fortran 1x2
- How I Overcame My Math Blocks.pdf
- Micro controller Lab Project
- Computer Concepts C Programming Dec 2012
- Bdc Recording
- Carte Sci Lab
- Subprocedures.pdf
- AbInitio Beginner's Course - Topic 4
- ~lecture11.pptx
- tournament.pdf
- h 1306 g Programing Language
- bhb
- FLUENT_2009April21_final.pdf

You are on page 1of 15

Name: Section:

During the exam you may:

You may not

For staff use: 1. 2. 3. 4. 5. 6. 7. total: /10 /20 /15 /8 /10 /12 /25 /100

Midterm 1 Spring 10

The following denitions have been entered into a Python shell:

class A:

yours = 0

def __init__(self, inp):

self.yours = inp def give(self, amt):

self.yours = self.yours + amt

return self.yours

def howmuch(self):

return (A.yours, self.yours)

class B(A):

yours = 0

def give(self, amt):

B.yours = B.yours + amt

return A.howmuch(self)

def take(self, amt):

self.yours = self.yours - amt

return self.yours

def howmuch(self):

return (B.yours, A.yours, self.yours)

Write the values of the following expressions. Write None when there is no value; write Error when an error results and explain briey why its an error. Assume that these expressions are evaluated one after another (all of the left column rst, then right column).

test = A(5) test = B(5)

test.take(2)

test.take(2)

test.give(6)

test.give(6)

test.howmuch()

test.howmuch()

Midterm 1 Spring 10

Here are some class denitions, meant to represent a collection of students making up the student body of a prestigious university.

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

nameOfSmartest: returns the name attribute of the student with the highest IQ funOfBest: takes a procedure fun and a procedure feature as input, and returns the result of applying procedure fun to the student for whom the procedure feature yields the highest value

For the rst two problems below, assume that these methods have been implemented.

Here is a student body:

chris = Student(Chris, 150, 40000, 62)

dana = Student(Dana, 120, 2000, 70)

aardvarkU = StudentBody()

aardvarkU.addStudent(jody)

aardvarkU.addStudent(chris)

aardvarkU.addStudent(dana)

2. Write a Python expression that will compute the name of the person who has the greatest value of IQ + height in aardvarkU (not just for the example student body above). You can dene additional procedures if you need them.

3. Implement the nameOfSmartest method. For full credit, use util.argmax (dened below) or the funOfBest method. If l is a list of items and f is a procedure that maps an item into a numeric score, then util.argmax(l, f) returns the element of l that has the highest score.

Midterm 1 Spring 10 4. Implement the funOfBest method. For full credit, use util.argmax.

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

jody = Student(Jody, 100, 100000, 80) chris = Student(Chris, 150, 40000, 62) dana = Student(Dana, 120, 2000, 70) aardvarkU = StudentBody() aardvarkU.addStudent(jody) aardvarkU.addStudent(chris) aardvarkU.addStudent(dana)

Midterm 1 Spring 10

3 SM to DE (15 Points)

Here is the denition of a class of state machines:

class Thing(SM):

startState = [0, 0, 0, 0]

def getNextValues(self, state, inp):

result = state[0] * 2 + state[2] * 3

newState = [state[1], result, state[3], inp]

return (newState, result)

Thing().transduce([1, 2, 0, 1, 3])

2. The state machine above describes the behavior of an LTI system starting at rest. Write a difference equation that describes the same system as the state machine.

Midterm 1 Spring 10

4 Diagnosis (8 points)

What, if anything, is wrong with each of the following state machine denitions? The syntax is correct (that is, they are all legal Python programs), so that is not a problem. Write a phrase or a single sentence if something is wrong or nothing if nothing is wrong. 1.

class M1(SM):

startState = 0

def getNextValues(self, state, inp):

return inp + state

2.

class M2(SM): startState = 0 def getNextValues(self, state, inp): return (inp+state, (state, state))

Midterm 1 Spring 10 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)

Midterm 1 Spring 10

Use sm.Gain, sm.Delay, sm.FeedbackAdd, sm.FeedbackSubtract, and sm.Cascade to make a state machine that is equivalent to the following system:

k1

+ R

k2 R R

Assume that the system starts at rest, that is, all the signals are zero at time zero. Assume also that the variables k1 and k2 are already dened. Recall that sm.Gain takes a gain as an argument, sm.Delay takes an initial output value as an argument and each of sm.Cascade, sm.FeedbackAdd, and sm.FeedbackSubtract, takes two state machines as arguments. Use indentation to highlight the structure of your answer.

Midterm 1 Spring 10

10

For each difference equation below, say whether, for a unit sample input signal:

the output of the system it describes will diverge or not, the output of the system it describes (a) will always be positive, (b) will alternate between positive and negative, or (c) will have a different pattern of oscillation

1.

diverge? Yes or No

positive/alternate/oscillate

2.

diverge? Yes or No positive/alternate/oscillate

Midterm 1 Spring 10

11

Sous vide cooking involves cooking food at a very precise, xed temperature T (typically, low enough to keep it moist, but high enough to kill any pathogens). In this problem, we model the behavior of the heater and water bath used for such cooking. Let I be the current going into the heater, and c be the proportionality constant such that Ic is the rate of heat input. The system is thus described by the following diagram:

Delay

k1

T I

Delay

k2

Midterm 1 Spring 10

12

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 .

200 200 150 150

100

100

50

50

10

15

10

15

50

50

a

200 200

150

150

100

100

50

50

10

15

10

15

50

50

c

200

200

150

150

100

100

50

50

10

15

10

15

50

50

e

a. Which of the plots above corresponds to k1 = 0.5 and k2 = 0 ? Circle all correct answers: a b c d e f none

b. Which of the plots above corresponds to k1 = 1 and k2 = 0.5 ? Circle all correct answers: a b c d e f none

Midterm 1 Spring 10 3. Let k1 = 0.5, k2 = 3, and c = 1. Determine the poles of H, or none if there are no poles.

13

14

Delay

k1

Delay

k2

Circle all of the following systems that are equivalent (for some setting of the gains in the triangles) to the original system.

Spring 2011

For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

- Technical Reference Manual - RAPID Instructions, Functions and Data TypeUploaded byMarcus Hardt Filho
- The Ring programming language version 1.5.1 book - Part 19 of 180Uploaded byMahmoud Samir Fayed
- f90Uploaded byRiccardo Cozza
- EN234FEA Tutorial 2017Uploaded byamd mhm
- 00 L CPU Syslib-rm017 -En-eUploaded byMd Micro
- messagebroker_ESQL v6.0Uploaded bysumit528
- SUB programUploaded byabhinay1111
- 02 Fortran 1x2Uploaded byapmapm
- How I Overcame My Math Blocks.pdfUploaded byIliut Nicolae
- Micro controller Lab ProjectUploaded byalwinarul88
- Computer Concepts C Programming Dec 2012Uploaded byPrasad C M
- Bdc RecordingUploaded bymahisapabap
- Carte Sci LabUploaded byAlin Grecu
- Subprocedures.pdfUploaded byBhasker Reddy
- AbInitio Beginner's Course - Topic 4Uploaded byaravindch
- ~lecture11.pptxUploaded byMir Fida Nadeem
- tournament.pdfUploaded byismael
- h 1306 g Programing LanguageUploaded byVirgiliu Dascal
- bhbUploaded bySalvador Moreno Luque
- FLUENT_2009April21_final.pdfUploaded byAnonymous GUitcVO
- test para tecnologia.pdfUploaded byNelson Ilbay
- Ctr.stanford.edu ResBriefs05 Schluter1Uploaded byVarghese Mathew
- Solved Question Papers and Hots of Class-XII IPUploaded byShraddha Maheshwari
- [Thesis]on MpCCI as a Coupling Library for FSI With CFXUploaded byLuong Anh
- CLM PROG.pdfUploaded byShhella Montenegro
- Chapter-4.pptUploaded byAnonymous fqheiHu
- sp11Uploaded bySaurabh Iyer
- Digital Computer Systems lecture 4Uploaded bySRA893
- Vita Programming Tutorial Part 1Uploaded byFagner Alves de Almeida
- Macro ProcessorsUploaded byCharanjit Kaur

- 244c1fc1f3981944e4c476320783462e2e050155Uploaded byapi-127299018
- 244c1fc1f3981944e4c476320783462e2e050155Uploaded byapi-127299018
- 244c1fc1f3981944e4c476320783462e2e050155Uploaded byapi-127299018
- 244c1fc1f3981944e4c476320783462e2e050155Uploaded byapi-127299018
- 244c1fc1f3981944e4c476320783462e2e050155Uploaded byapi-127299018
- 244c1fc1f3981944e4c476320783462e2e050155Uploaded byapi-127299018
- b151d72e4b9391412234cd9302dd07e679cc861aUploaded byapi-127299018
- 702a75fe02ff62e5ae5b74646d18da512a724d02Uploaded byapi-127299018
- f7895136c515d2e469f0a12e5c6c54190d8b4be1Uploaded byapi-127299018
- 0700244a1fd879268cc3abce8d4f02a44526f738Uploaded byapi-127299018
- Rm Chapter 1Uploaded byBrandon Ayala
- 23b8563760685fae18fea95b388f930edafaa7deUploaded byapi-127299018
- fd35a5c22ca4c8787de76166eded73a103ad02afUploaded byapi-127299018
- 9466be5cdea34cb0098f8e82846e2268fc3aca7dUploaded byapi-127299018
- 84cc54402d20f47cfb17a201658f04d3414edd9bUploaded byapi-127299018
- b151d72e4b9391412234cd9302dd07e679cc861aUploaded byapi-127299018
- 187e9e5268ed74af09b10b60a622384cec2efa74Uploaded byapi-127299018
- 196040ff93bae9c9df8453dd90baad58c99544feUploaded byapi-127299018
- 196040ff93bae9c9df8453dd90baad58c99544feUploaded byapi-127299018
- 196040ff93bae9c9df8453dd90baad58c99544feUploaded byapi-127299018
- 196040ff93bae9c9df8453dd90baad58c99544feUploaded byapi-127299018
- 196040ff93bae9c9df8453dd90baad58c99544feUploaded byapi-127299018
- 196040ff93bae9c9df8453dd90baad58c99544feUploaded byapi-127299018
- 196040ff93bae9c9df8453dd90baad58c99544feUploaded byapi-127299018
- 196040ff93bae9c9df8453dd90baad58c99544feUploaded byapi-127299018
- 196040ff93bae9c9df8453dd90baad58c99544feUploaded byapi-127299018
- 125c5da1e1b8536345a1c6a9876c51b5653bed34Uploaded byapi-127299018
- fd35a5c22ca4c8787de76166eded73a103ad02afUploaded byapi-127299018
- fd35a5c22ca4c8787de76166eded73a103ad02afUploaded byapi-127299018
- UntitledUploaded byapi-127299018

- bankers-adda_-how-to-crack-sbi-po-2014-exam-in-2-months_.pdfUploaded bysonalibhimte
- Deep Photo StyleUploaded byIamIN
- The chemistry of spicesUploaded bylordregulus
- Red Cross: New CEO AnnouncementUploaded byChad Douglas Johnson, MPA
- Care3Plus Manuale ENGUploaded bytopobuccia
- Guide to Reducing the Cost of Metal Stamped PartsUploaded bymanortool
- Marketing of perishable goods in BangladeshUploaded bydeath_heaven
- Glossary Chapter 6Uploaded byZhwan Raouf
- DSR-500N DSR-1000N_A1_QIG_v1.01(WW)Uploaded byPolarograma
- _htaccess Cheat Sheet - All Rules You Will Ever Need, Listed on One Page for ApacheUploaded byMichael Smith
- PDF SAM4S AtmelUploaded byDionata Nunes Elisa Massena
- Pronouns and Articles in MarathiUploaded bydnvairam
- BizhubProC500-C8150Uploaded bytytech7
- Electricity and Magnetism 5Uploaded byLuis Benavides
- m2 - Egg DishesUploaded byMimi Chomel
- INA333 Instrumentation AmplifierUploaded byr96221029
- Enrichment PaperUploaded byGrupo Monteverdi
- Dales Cone of ExperienceUploaded byDjukarnaDjapri
- Gravity Lab - Advanced VersionUploaded byTeachLABScI
- Case Study - APECUploaded byAl Farisi
- Decision Making in Robotics and PhycologyUploaded byFeline Fatale
- HiFi Guide To CablesUploaded byFrancisco Russo
- Rational Comprehensive ModelUploaded byapi-3707305
- ADMS 2510 Chapter 1 NotesUploaded byemahal16
- 10CSL57-2012Uploaded bySeo Nikitha
- 70-465 Exam Dumps With PDF and VCE DownloadUploaded byrodolfosimoes
- United States v. California, 507 U.S. 746 (1993)Uploaded byScribd Government Docs
- Maruti Communication StrategyUploaded bydebaion
- Promotion and Distribution ManagementUploaded bySantosh Kumar
- MBA Batch 10 - Principles of Management COURSE SESSION PLANUploaded bymikhil.murali