【发布时间】:2021-12-19 21:22:19
【问题描述】:
我是 python 语言的新手,我无法在我的书中找到如何编写这些函数。他们大多用伪代码编写,并希望您只知道如何准确编码。在我花了几个小时搜索没有结果之前,我想寻求帮助。
这个程序应该获取用户的房价并找到中位数、平均值、最大值和最小值。
#This program asks for prices of houses from the user, then it takes the input
#and calculates the AVG, MAX, MIN, and MED.
print(" Real Estate Program ")
print()
print("**********************************************************************")
#Will get the user's input about the price houses in their area
prices = []
cost = 0
while cost != -99:
cost = input("Enter cost of one home or -99 to quit: ")
prices.append(cost)
if cost == "-99":
break
else:
continue
print("*********************************************************************")
#removes -99 from list
prices.pop(-1)
print("Prices of homes in your area:")
print(prices)
print()
#this find the maximum value of the houses
print ("The maximum sale price is:", max(prices))
#this find the minimum value of the houses
print ("The minimum sale price is:", min(prices))
【问题讨论】:
-
这能回答你的问题吗? Finding the average of a listFinding median of list in python。绝对花了不到一分钟的时间搜索得到这些结果仅供参考
标签: python python-3.x list