Trying to solve fancy house in python data structure | Sololearn: Learn to code for FREE!

0

Trying to solve fancy house in python data structure

Here is the code i tried Don't know what is wrong with my code prices = [125000, 78000, 110000, 65000, 300000, 250000, 210000, 150000, 165000, 140000, 125000, 85000, 90000, 128000, 230000, 225000, 100000, 300000] x = sum(prices) y=len(prices) d=(x/y) print(len(prices)>d) Here is the question You are analyzing house prices. The given code declares a list with house prices in the neighborhood. You need to calculate and output the number of houses that have a price that is above the average. To calculate the average price of the houses, you need to divide the sum of all prices by the number of houses.

4/12/2021 7:08:43 AM

Simisola Osinowo

14 Answers

New Answer

+3

#Try this prices = [125000, 78000, 110000, 65000, 300000, 250000, 210000, 150000, 165000, 140000, 125000, 85000, 90000, 128000, 230000, 225000, 100000, 300000] x = sum(prices) y=len(prices) d=(x/y) count = 0 for i in prices: if i > d: count+=1 print(count)

+2

You are analyzing house prices. The given code declares a list with house prices in the neighborhood. You need to calculate and output the number of houses that have a price that is above the average. prices = [125000, 78000, 110000, 65000, 300000, 250000, 210000, 150000, 165000, 140000, 125000, 85000, 90000, 128000, 230000, 225000, 100000, 300000] #your code goes here mid_price = sum(prices)/ len(prices) hight_price = 0 for i in prices: if i> mid_price: hight_price+=1 print(hight_price)

+1

prices = [125000, 78000, 110000, 65000, 300000, 250000, 210000, 150000, 165000, 140000, 125000, 85000, 90000, 128000, 230000, 225000, 100000, 300000] #your code goes here avg = sum(prices) / len(prices) print(sum(i > avg for i in prices))

+1

average=sum(prices)/len(prices) x =(list(filter(lambda x: x> average,prices))) print(len(x))

0

U need mean ± standard mean >=

0

And for percent * 100

0

I don't understand what you mean

0

I mean, you haven't read the conditions of task accurately enough

0

You are analyzing house prices. The given code declares a list with house prices in the neighborhood. You need to calculate and output the number of houses that have a price that is above the average. To calculate the average price of the houses, you need to divide the sum of all prices by the number of houses. Use sum(list) to calculate the sum of all items in the list and len(list) to get the number of items.

0

Ah OK, i think its task from data science, u need count of house more then x/y for this u can use loop for generate new list, or u can use filter. len(list(filter(lambda x: x>d,prices)))

0

Thanks it worked

0

try this code prices = [125000, 78000, 110000, 65000, 300000, 250000, 210000, 150000, 165000, 140000, 125000, 85000, 90000, 128000, 230000, 225000, 100000, 300000] #your code goes here avg = sum(prices)/len(prices) lst = 0 for i in prices: if i > avg: lst += 1 print(lst)

0

prices = [125000, 78000, 110000, 65000, 300000, 250000, 210000, 150000, 165000, 140000, 125000, 85000, 90000, 128000, 230000, 225000, 100000, 300000] #your code goes here total= sum([prices[x] for x in range(len(prices))])/len(prices) nbr=0 for x in prices: if x > total: nbr = nbr + 1 print(nbr)

0

prices = [125000, 78000, 110000, 65000, 300000, 250000, 210000, 150000, 165000, 140000, 125000, 85000, 90000, 128000, 230000, 225000, 100000, 300000] #your code goes here total = sum(prices) length = len(prices) avg= total/length above_avg_houses =[price for price in prices if price > avg ] print(len(above_avg_houses)) try this with list comprehension python