TutorMe homepage

SIGN IN

Start Free Trial

Andrew G.

Student Tutor

Tutor Satisfaction Guarantee

Python Programming

TutorMe

Question:

Write the necessary code to create the following user-defined class in Python, Car that has the following attributes i.) A constructor that takes in three parameters (in addition to the 'self' parameter) color, year, model ii.) Getters and setters for the above parameters iii.) A method called __str__ that allows for a Car object to be passed to the print function and output the following "This car is a {color}, {year}, {model}" with the {color},{year}, and {model} fields replaced with the corresponding Car object's variables. iv.) A method called calcClassic that takes in no parameters and prints out the year that the car will be considered a classic (take classic to mean a vehicle that is 50 years old relative to the current year)

Andrew G.

Answer:

class Car: def __init__(self, color, year, model): self.color = color self.year = year self.model = model def __str__(self): return "This car is a " + self.color + "," + str(self.year) + "," + self.model def getColor(self): return self.color def setColor(self, color): self.color = color def getYear(self): return self.year def setYear(self, year): self.year = year def getModel(self): return self.model def setModel(self, model): self.model = model def calcClassic(self): calcYear = int(self.year) + 50 print("This car will be a classic in the year, " + str(calcYear))

Linear Algebra

TutorMe

Question:

Consider the vector in $$R^3$$ given as $$v = (1,2,3)$$ i.)Find a 3x3 matrix $$A$$ (with respect to the standard basis of $$R^3$$) such that $$Av = (2,9,5)$$ ii.) Is $$A$$ invertible, why or why not?

Andrew G.

Answer:

i.) Consider the vector, v, as a linear combination of the following 3 vectors $$v_1 = (1,0,0)$$ $$v_2 = (0,2,0)$$ $$v_3 = (0,0,3)$$ The columns of the matrix $$A$$ will correspond to $$A$$ applied to each of the above vectors (because the above vectors combine to equal v and because each of the above vectors is a scalar multiple of each corresponding standard basis vector in $$R^3$$ therefore $$A = (Av_1, Av_2, Av_3) \\ = ((2,0,0),(0,\frac{9}{2},0),(0,0,\frac{5}{3}))$$ ii.)The matrix $$A$$ is invertible Because $$A$$ is a diagonal matrix, its determinant can be calculated by taking the product of the diagonals $$det(A) = 2 * \frac{9}{2} * \frac{5}{3} = 15$$ Because $$det(A) \neq 0$$, $$A$$ is invertible

Calculus

TutorMe

Question:

Consider the function given by $$f(x) = sin^2(x)$$ on the interval $$[-\pi, \pi$$] i.) Find $$f'(x)$$ on $$[-\pi, \pi]$$ ii.)Find the maximum and minimum of $$f(x)$$ on $$[-\pi,\pi]$$ iii.)Find $$\int f(x) dx$$ iv.)Find the area under the curve given by $$f(x)$$ on the interval $$[-\pi, \pi]$$

Andrew G.

Answer:

i.) $$\frac{df(x)}{dx} \\= \frac{d}{dx}f(x) \\= \frac{d}{dx}sin^2(x)\\ = 2sin(x) * \frac{d}{dx} (sin(x)) \\= 2sin(x)cos(x) \\= sin(2x)$$ ii.) $$f'(x) = 0$$ $$\rightarrow sin(2x) = 0$$ $$\rightarrow x = -\pi, 0, \pi$$ $$f(-\pi) = sin^2(-\pi) = 1$$ $$f(0) = sin^2(0) = 0$$ $$f(\pi) = sin^2(\pi) = 1$$ Therefore, because the endpoints of the interval are critical points as well, the maximum of $$f(x)$$ on $$[-\pi,\pi]$$ is 1 and the minimum of $$f(x)$$ on $$[-\pi,\pi,]$$ is 0 iii.) $$\int f(x)dx = \int sin^2(x)dx \\= \int \frac{1}{2} - \frac{cos(2x)}{2} dx \\= \frac{x}{2} - \int \frac{cos(2x)}{2}dx \\ = \frac{x}{2} - \frac{sin(2x)}{4} + C$$ iv.) The area under the curve described by $$f(x)$$ is equal to $$\int_{-\pi}^{\pi}f(x)dx$$ $$\int_{-\pi}^{\pi}f(x)dx = (\frac{x}{2} - \frac{sin(2x)}{4} + C) \bigg|_{-\pi}^{\pi} \\ = (\frac{\pi}{2} - \frac{sin(2\pi)}{4} + C) - (\frac{-\pi}{2} - \frac{sin(-2\pi)}{4} + C) \\= \pi$$

Send a message explaining your

needs and Andrew will reply soon.

needs and Andrew will reply soon.

Contact Andrew

Ready now? Request a lesson.

Start Session

FAQs

What is a lesson?

A lesson is virtual lesson space on our platform where you and a tutor can communicate.
You'll have the option to communicate using video/audio as well as text chat.
You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.

How do I begin a lesson?

If the tutor is currently online, you can click the "Start Session" button above.
If they are offline, you can always send them a message to schedule a lesson.

Who are TutorMe tutors?

Many of our tutors are current college students or recent graduates of top-tier universities
like MIT, Harvard and USC.
TutorMe has thousands of top-quality tutors available to work with you.

Made in California

© 2019 TutorMe.com, Inc.