# Tutor profile: Austin C.

## Questions

### Subject: Python Programming

Write an example of a class named "car" which has values of number of passengers, car model, and gas mileage. Write an init function for this class.

$$ class\ \ Car:\\ \quad passengers = 0\\ \quad\ model = None\\\quad\ mpg = 0\\ \ \\\quad\ def\quad \_\_init\_\_(self,\ \ \_passengers : int,\ \ \_model: str,\ \ \_mpg: float):\\\quad\quad\ \ self.passengers = \_passengers\\\quad\quad\ \ \ self.model = \_model\\ \quad\quad\ \ \ self.mpg = \_mpg$$

### Subject: iOS Programming

How do you lazily initialize a UIView in a View Controller? Write the code for this and explain why lazy initialization is a good practice.

The code (Objective-C): $$-\quad(UIView *)myView$$ $$\{$$ $$\quad\quad\quad if(!\_myView) \{$$ $$\quad\quad\quad\quad\quad\quad \_myView = [[UIView\ \ alloc]\ \ initWithFrame: CGRectZero];$$ $$\quad\quad\quad\}$$ $$\quad\quad\quad return\ \ myView$$ $$\}$$ The code (Swift): $$lazy\ \ var\ \ myView: UIView= \{$$ $$\quad\quad\quad[unowned\ \ self]\ \ in$$ $$\quad\quad\quad return\ \ UIView(frame:\ \ CGRect.zero) $$ $$\}()$$ It is proper practice to use lazy initialization because we do not want to waste memory and processing time creating objects unless we are going to use the objects we create. Lazy initialization places the initialization of an object in its getter function, so the memory is allocated and the object is created once we call it in the code, and not before.

### Subject: Calculus

What is the derivative of $$3\cdot ln(x^{2})$$? Show each step in the process of taking this derivative.

The derivate of $$3\cdot ln(x^{2})$$ is $$\frac{6}{x}$$. This can be found by taking the following steps: 1. Use the chain rule to evaluate $$ln(x^{2})$$. a. Evaluate the integral inside: $$\frac{d}{dx}[x^{2}] = 2x$$. b. Evaluate the integral outside using the log rule: $$\frac{d}{dx}[ln(a)] = \frac{1}{a}$$. c. Multiply these together to get this result: $$\frac{d}{dx}[ln(x^{2})] = \frac{2x}{x^{2}} = \frac{2}{x}$$. 2. Multiply this by 3 to get the result: $$3\cdot \frac{2}{x} = \frac{6}{x}$$

## Contact tutor

needs and Austin will reply soon.