SlideShare a Scribd company logo
1 of 22
For any help regarding Python Homework Help
visit : - https://www.pythonhomeworkhelp.com/,
Email :- support@pythonhomeworkhelp.com or
call us at :- +1 678 648 4277
1 OOP
The following definitions 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 briefly why it’s an error. Assume that these
expressions are evaluated one after another (all of the left column first, then right
column).
test = A(5)
None
test.take(2)
Error
test.give(6)
11
test.howmuch()
(0, 11)
test = B(5)
None
test.take(2)
3
test.give(6)
(0, 3)
test.howmuch()
(6, 0, 3)
2 The Best and the Brightest
Here are some class definitions, 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
The StudentBody class is missing the code for two methods:
• 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 first two problems below, assume that these methods have been implemented.
Here is a student body:
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)
1. What is the result of evaluating aardvarkU.nameOfSmartest()?
’Chris’
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 define additional procedures if you need them.
aardvarkU.funOfBest(lambda x: x.name, lambda x: x.iq + x.height)
3. Implement the nameOfSmartest method. For full credit, use util.argmax (defined
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.
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)
4. Implement the funOfBest method. For full credit, use util.argmax.
def funOfBest(self, fun, feature):
return fun(util.argmax(self.students, feature))
Repeated from the start of the problem:
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
Here is a student body:
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)
3 SM to DE
Here is the definition 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)
1. What is the result of evaluating
Thing().transduce([1, 2, 0, 1, 3])
[0, 0, 3, 6, 6]
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.
y[n] = 2 * y[n-2] + 3 * x[n - 2]
4 Diagnosis
What, if anything, is wrong with each of the following state machine definitions? 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
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
This modifies the state argument, by doing state.append(inp)
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)
This modifies the attribute value in getNextValues.
5 Picture to Machine
Use sm.Gain, sm.Delay, sm.FeedbackAdd, sm.FeedbackSubtract, and sm.Cascade to
make a state machine that is equivalent to the following system:
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 defined.
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.
FeedbackSubtract(Cascade(Cascade(Gain(k1), R()),
FeedbackSubtract(Gain(k2),
Cascade(R(),R()))),
R())
6 On the Verge
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.
10y[n] − y[n − 1] = 8x[n − 3]
diverge? Yes or No No
positive/alternate/oscillate Positive
2.
y[n] = −y[n − 1] − 10y[n − 2] + x[n]
diverge? Yes or No Yes
positive/alternate/oscillate Oscillates, pole is complex
7 What’s Cooking?
Sous vide cooking involves cooking food at a very precise, fixed 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:
1. a. Give the system function: H = T/I =
b. Give a difference equation for the system: T[n] =
T[n] = (k1 − k2)T[n − 1] + k1k2T[n − 2] + cI[n]
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 ?
Circle all correct answers:
b. Which of the plots above corresponds to a b k1 = 1 and k2 = 0.5 ?
Circle all correct answers:
3. Let k1 = 0.5, k2 = 3, and c = 1. Determine the poles of H, or none if there are no poles.
Poles at 0.5 and -3
4. Here is the original system:
Circle all of the following systems that are equivalent (for some setting of the gains in
the triangles) to the original system.
System b has the same system function. System e has the same poles. We required b
to be circled, and considered e to be correct whether circled or not.

More Related Content

What's hot

finding Min and max element from given array using divide & conquer
finding Min and max element from given array using  divide & conquer finding Min and max element from given array using  divide & conquer
finding Min and max element from given array using divide & conquer Swati Kulkarni Jaipurkar
 
Multiclass Logistic Regression: Derivation and Apache Spark Examples
Multiclass Logistic Regression: Derivation and Apache Spark ExamplesMulticlass Logistic Regression: Derivation and Apache Spark Examples
Multiclass Logistic Regression: Derivation and Apache Spark ExamplesMarjan Sterjev
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and boundAbhishek Singh
 
Deterministic finite automata
Deterministic finite automata Deterministic finite automata
Deterministic finite automata Muhammad Love Kian
 
Solution of matlab chapter 6
Solution of matlab chapter 6Solution of matlab chapter 6
Solution of matlab chapter 6AhsanIrshad8
 
Integration by Parts, Part 3
Integration by Parts, Part 3Integration by Parts, Part 3
Integration by Parts, Part 3Pablo Antuna
 
Programming in lua STRING AND ARRAY
Programming in lua STRING AND ARRAYProgramming in lua STRING AND ARRAY
Programming in lua STRING AND ARRAYvikram mahendra
 
Solution of matlab chapter 1
Solution of matlab chapter 1Solution of matlab chapter 1
Solution of matlab chapter 1AhsanIrshad8
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithmspppepito86
 
signal and system Hw2 solution
signal and system Hw2 solutionsignal and system Hw2 solution
signal and system Hw2 solutioniqbal ahmad
 
Sienna 10 dynamic
Sienna 10 dynamicSienna 10 dynamic
Sienna 10 dynamicchidabdu
 
Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2Scilab
 
Scilab for real dummies j.heikell - part3
Scilab for real dummies j.heikell - part3Scilab for real dummies j.heikell - part3
Scilab for real dummies j.heikell - part3Scilab
 
knapsackusingbranchandbound
knapsackusingbranchandboundknapsackusingbranchandbound
knapsackusingbranchandboundhodcsencet
 

What's hot (19)

Chap12alg
Chap12algChap12alg
Chap12alg
 
Ch3
Ch3Ch3
Ch3
 
finding Min and max element from given array using divide & conquer
finding Min and max element from given array using  divide & conquer finding Min and max element from given array using  divide & conquer
finding Min and max element from given array using divide & conquer
 
Multiclass Logistic Regression: Derivation and Apache Spark Examples
Multiclass Logistic Regression: Derivation and Apache Spark ExamplesMulticlass Logistic Regression: Derivation and Apache Spark Examples
Multiclass Logistic Regression: Derivation and Apache Spark Examples
 
Divide and Conquer
Divide and ConquerDivide and Conquer
Divide and Conquer
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and bound
 
Deterministic finite automata
Deterministic finite automata Deterministic finite automata
Deterministic finite automata
 
Solution of matlab chapter 6
Solution of matlab chapter 6Solution of matlab chapter 6
Solution of matlab chapter 6
 
Tutorial 2
Tutorial     2Tutorial     2
Tutorial 2
 
Integration by Parts, Part 3
Integration by Parts, Part 3Integration by Parts, Part 3
Integration by Parts, Part 3
 
Programming in lua STRING AND ARRAY
Programming in lua STRING AND ARRAYProgramming in lua STRING AND ARRAY
Programming in lua STRING AND ARRAY
 
Solution of matlab chapter 1
Solution of matlab chapter 1Solution of matlab chapter 1
Solution of matlab chapter 1
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
 
signal and system Hw2 solution
signal and system Hw2 solutionsignal and system Hw2 solution
signal and system Hw2 solution
 
Sienna 10 dynamic
Sienna 10 dynamicSienna 10 dynamic
Sienna 10 dynamic
 
Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2
 
Scilab for real dummies j.heikell - part3
Scilab for real dummies j.heikell - part3Scilab for real dummies j.heikell - part3
Scilab for real dummies j.heikell - part3
 
knapsackusingbranchandbound
knapsackusingbranchandboundknapsackusingbranchandbound
knapsackusingbranchandbound
 
algorithm Unit 4
algorithm Unit 4 algorithm Unit 4
algorithm Unit 4
 

Similar to Python Homework Help Guide

Python Programming Homework Help.pptx
Python Programming Homework Help.pptxPython Programming Homework Help.pptx
Python Programming Homework Help.pptxPython Homework Help
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxanhlodge
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance HaskellJohan Tibell
 
lecture 23
lecture 23lecture 23
lecture 23sajinsc
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxagnesdcarey33086
 
PID Tuning using Ziegler Nicholas - MATLAB Approach
PID Tuning using Ziegler Nicholas - MATLAB ApproachPID Tuning using Ziegler Nicholas - MATLAB Approach
PID Tuning using Ziegler Nicholas - MATLAB ApproachWaleed El-Badry
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentationManchireddy Reddy
 
Problem descriptionThe Jim Thornton Coffee House chain is .docx
Problem descriptionThe Jim Thornton Coffee House chain is .docxProblem descriptionThe Jim Thornton Coffee House chain is .docx
Problem descriptionThe Jim Thornton Coffee House chain is .docxelishaoatway
 
object oriented programming java lectures
object oriented programming java lecturesobject oriented programming java lectures
object oriented programming java lecturesMSohaib24
 
Dynamic1
Dynamic1Dynamic1
Dynamic1MyAlome
 

Similar to Python Homework Help Guide (20)

Quality Python Homework Help
Quality Python Homework HelpQuality Python Homework Help
Quality Python Homework Help
 
Python Programming Homework Help.pptx
Python Programming Homework Help.pptxPython Programming Homework Help.pptx
Python Programming Homework Help.pptx
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
 
Ada boost
Ada boostAda boost
Ada boost
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance Haskell
 
Mechanical Engineering Assignment Help
Mechanical Engineering Assignment HelpMechanical Engineering Assignment Help
Mechanical Engineering Assignment Help
 
Signals and Systems Homework Help.pptx
Signals and Systems Homework Help.pptxSignals and Systems Homework Help.pptx
Signals and Systems Homework Help.pptx
 
Midterm
MidtermMidterm
Midterm
 
lecture 23
lecture 23lecture 23
lecture 23
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
 
PID Tuning using Ziegler Nicholas - MATLAB Approach
PID Tuning using Ziegler Nicholas - MATLAB ApproachPID Tuning using Ziegler Nicholas - MATLAB Approach
PID Tuning using Ziegler Nicholas - MATLAB Approach
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
 
Servo systems
Servo systemsServo systems
Servo systems
 
ScalaMeter 2014
ScalaMeter 2014ScalaMeter 2014
ScalaMeter 2014
 
Assignment2 control
Assignment2 controlAssignment2 control
Assignment2 control
 
Control assignment#2
Control assignment#2Control assignment#2
Control assignment#2
 
Problem descriptionThe Jim Thornton Coffee House chain is .docx
Problem descriptionThe Jim Thornton Coffee House chain is .docxProblem descriptionThe Jim Thornton Coffee House chain is .docx
Problem descriptionThe Jim Thornton Coffee House chain is .docx
 
object oriented programming java lectures
object oriented programming java lecturesobject oriented programming java lectures
object oriented programming java lectures
 
Dynamic1
Dynamic1Dynamic1
Dynamic1
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 

More from Python Homework Help

Introduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptxIntroduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 

More from Python Homework Help (20)

Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Complete my Python Homework
Complete my Python HomeworkComplete my Python Homework
Complete my Python Homework
 
Introduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptxIntroduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptx
 
Basic Python Programming.pptx
Basic Python Programming.pptxBasic Python Programming.pptx
Basic Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Quality Python Homework Help
Quality Python Homework HelpQuality Python Homework Help
Quality Python Homework Help
 
Perfect Python Homework Help
Perfect Python Homework HelpPerfect Python Homework Help
Perfect Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Programming Homework Help
Python Programming Homework HelpPython Programming Homework Help
Python Programming Homework Help
 

Recently uploaded

Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 

Recently uploaded (20)

Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 

Python Homework Help Guide

  • 1. For any help regarding Python Homework Help visit : - https://www.pythonhomeworkhelp.com/, Email :- support@pythonhomeworkhelp.com or call us at :- +1 678 648 4277
  • 2. 1 OOP The following definitions 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)
  • 3. Write the values of the following expressions. Write None when there is no value; write Error when an error results and explain briefly why it’s an error. Assume that these expressions are evaluated one after another (all of the left column first, then right column). test = A(5) None test.take(2) Error test.give(6) 11 test.howmuch() (0, 11) test = B(5) None test.take(2) 3 test.give(6) (0, 3) test.howmuch() (6, 0, 3)
  • 4. 2 The Best and the Brightest Here are some class definitions, 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
  • 5. The StudentBody class is missing the code for two methods: • 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 first two problems below, assume that these methods have been implemented. Here is a student body: 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)
  • 6. 1. What is the result of evaluating aardvarkU.nameOfSmartest()? ’Chris’ 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 define additional procedures if you need them. aardvarkU.funOfBest(lambda x: x.name, lambda x: x.iq + x.height) 3. Implement the nameOfSmartest method. For full credit, use util.argmax (defined below) or the funOfBest method.
  • 7. 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. 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) 4. Implement the funOfBest method. For full credit, use util.argmax.
  • 8. def funOfBest(self, fun, feature): return fun(util.argmax(self.students, feature)) Repeated from the start of the problem: 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):
  • 9. self.student.append(student) def deleteStudent(self, student): self.students.remove(student) def nameOfSmartest(self): pass def funOfBest(self, fun, feature): pass Here is a student body: 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) 3 SM to DE Here is the definition of a class of state machines:
  • 10. 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) 1. What is the result of evaluating Thing().transduce([1, 2, 0, 1, 3]) [0, 0, 3, 6, 6] 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.
  • 11. y[n] = 2 * y[n-2] + 3 * x[n - 2] 4 Diagnosis What, if anything, is wrong with each of the following state machine definitions? 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
  • 12. 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]
  • 13. def getNextValues(self, state, inp): state.append(inp) result = sum(state) / float(len(state)) return (result, state This modifies the state argument, by doing state.append(inp) 4. class M4(SM): startState = -1 def __init__(self, v): self.value = v def getNextValues(self, state, inp):
  • 14. if state > inp: self.value = self.value + state result = self.value * 2 return (state, result) This modifies the attribute value in getNextValues. 5 Picture to Machine Use sm.Gain, sm.Delay, sm.FeedbackAdd, sm.FeedbackSubtract, and sm.Cascade to make a state machine that is equivalent to the following system:
  • 15. 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 defined. 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. FeedbackSubtract(Cascade(Cascade(Gain(k1), R()), FeedbackSubtract(Gain(k2), Cascade(R(),R()))), R()) 6 On the Verge For each difference equation below, say whether, for a unit sample input signal:
  • 16. • 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. 10y[n] − y[n − 1] = 8x[n − 3] diverge? Yes or No No positive/alternate/oscillate Positive 2. y[n] = −y[n − 1] − 10y[n − 2] + x[n] diverge? Yes or No Yes
  • 17. positive/alternate/oscillate Oscillates, pole is complex 7 What’s Cooking? Sous vide cooking involves cooking food at a very precise, fixed 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: 1. a. Give the system function: H = T/I =
  • 18. b. Give a difference equation for the system: T[n] = T[n] = (k1 − k2)T[n − 1] + k1k2T[n − 2] + cI[n] 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.
  • 19.
  • 20. a. Which of the plots above corresponds to k1 = 0.5 and k2 = 0 ? Circle all correct answers: b. Which of the plots above corresponds to a b k1 = 1 and k2 = 0.5 ? Circle all correct answers: 3. Let k1 = 0.5, k2 = 3, and c = 1. Determine the poles of H, or none if there are no poles. Poles at 0.5 and -3 4. Here is the original system:
  • 21. Circle all of the following systems that are equivalent (for some setting of the gains in the triangles) to the original system.
  • 22. System b has the same system function. System e has the same poles. We required b to be circled, and considered e to be correct whether circled or not.