QUESTION

Text
Image

# Hi, I am looking for help with the following Python problem. Looking for a complete solution that has been explained, thanks.1. Price to Sell A real estate agent is advising a seller on the price to ask for a home. To do this, the agent will look at homes that have sold in the area and base the valuation on this data. The only factors that will be considered are square footage and sale price. The agent starts by removing any outliers from the list of comparable homes. To determine the outliers: - Select the home to test. - Create a list of prices of other homes of the same size. It will be called complist in the examples. - If there are no other homes of the same size, the house being tested is not an outlier. - Otherwise: - Calculate the mean price, $P_{m}$ and the standard deviation, $\sigma$, for the homes complist. - If $\mid$ price[i] $-P_{m} \mid>3 * \sigma$, the house is an outlier. The valuation is then calculated against the resulting list using the following rules: - If there are no houses in the list, use 1000 per square foot as the price. - If there is only 1 house in the list, its square foot price is used. - If there are 1 or more houses in the list with the exact square footage of the house to price, use the mean of those prices. - If the required square footage is between the square footage of two houses in the list, interpolate the square foot price using the means of the closest higher and lower-priced homes. - If the required square footage is outside of the range of houses listed, extrapolate the price based on the means of the two square footage values that are closest to the home to value. In all cases, if the final price is less than $10^{3}$ or greater than $10^{6}$, the price will be $10^{3}$ and $10^{6}$, respectively. For any square footage, the square foot price is the mean of the prices at that square footage. Return an integer that represents the valuation of the seller's house.For example, there are $n=6$ houses with area $=[1200,1300,1200$, $1300,1200,2000]$, price $=[12000,24000,14000,22000,13000$, $30000]$ and the house to value has reqArea $=1500$ square feet. The following table shows the test for outliers: * There is only one house with this area, so it cannot be an outlier. The 1300 square foot houses are both outliers, so they are discarded. The new arrays are area' $=[1200,1200,1200,2000]$ and price $^{\prime}=[12000,14000,13000,30000]$. Interpolate the price between the two house sizes remaining. The interpolated price is $13000+(30000-13000) /(2000-1200) *(1500-1200)=19375$. Function Description Complete the function valuation in the editor below. The function must return the expected price rounded to the nearest integer. valuation has the following parameter(s): int reqArea: the area of the seller's house in square feet int area[n]: each value is an area of a house sold in the past int price[n]: price[i] is the price of the $i$ th house in area[]Constraints - $500 \leq$ reqArea $\leq 10^{5}$ - $500 \leq$ area $[i] \leq 10^{5}$ for all $i$ such that $0 \leq i<n$ - $10^{3} \leq$ price $[i] \leq 10^{6}$ for all $i$ such that $0 \leq i<n$ - $1 \leq n \leq 10^{5}$ Input Format For Custom Testing The first line contains an integer, reqArea, the area of the house required. The second line contains an integer, $n$, the size of the array area. Each line $i$ of the $\mathrm{n}$ subsequent lines (where $0 \leq i<n$ ) contains an integer that describes area[i]. The next line again contains the integer, $n$, the size of the array price. Each line $i$ of the $n$ subsequent lines (where $0 \leq i<n$ ) contains an integer that describes price[i]. $\checkmark$ Sample Case 0 Sample Input For Custom Testing $\begin{array}{lll} \text { STDIN } & \multicolumn{2}{l}{\text { Function }} \\ ---- & ----- \\ 1200 & \rightarrow \text { reqArea }=1200 \\ 5 & \rightarrow \text { area }[] \mathrm{size} \mathrm{n}=5 \\ 1500 \rightarrow \text { area }=[1500,500,1000,2000,2500] \\ 500 & \\ 1000 & \\ 2000 & \\ 2500 & \\ 5 & \rightarrow \text { price }[] \operatorname{size} \mathrm{n}=5 \\ 30000 & \rightarrow \text { price }=[30000,10000,20000,40000,50000] \\ 10000 & \\ 20000 & \\ 40000 & \\ 50000 & \end{array}$ Sample Output 24000  