#!/usr/bin/env python3 # This program uses input from the user to calculate the median, average, minimum, and maximum sale prices of a group of homes # display welcome message print ("Real Estate Values") print () # function to sort the list def sorting (List) : #return the sorted list return List.sort () # function to find the median cost def medianValue (List) : # find the length of the list length=len (List) # find middle item of the list middleItem-length//2 # if length is even if length%2==0: # return the median cost return (List [middleItem] +List [middleItem-l])/2 # if length is odd anTRAURTRa else: #return the median cost return List [middleItem] #function to find the average cost def average (List) : #find the length of the list length=len (List) #calculate the total cost totalCost=sum (List) #return the average cost return totalCost/length #main function def main () : #create an empty list costList=[ #prompt user to enter house cost cost=int (input ('Enter the cost of one home or -99 to quit:') ) while (cost!=-99) : #add element in the list CostList.append (cost) #prompt user to enter the house cost COst=int cost=int (input ('Enter the cost of one home or --99 to quit:')) #display statement print ("****** #display statement print ("Prices of homes in your area:") ********") #call the sorting function to sort the list sorting (costList) #display the sorted list print (costList) #display statement print ("**k******* #call and display the median cost print ("The median value is $", medianValue (costList)) #call and display the average cost print ("The average sale price is $", average (costList) ) ******") #display the minimum cost print ("The minimum sale price is $", min (costList)) #display the maximum cost print ("The maximum sale price is $", max (costList)) #calling main function main ()

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

This is a Python program to calculate median, average, minimum, and maximum home values from a list.

How can I format the output to look like dollar values?

Can I round the output to 2 decimal places?

Can I display commas in the output values?

#!/usr/bin/env python3
# This program uses input from the user to calculate the median, average, minimum, and maximum sale prices of a group of homes
# display welcome message
print ("Real Estate Values")
print ()
# function to sort the list
def sorting (List) :
#return the sorted list
return List.sort ()
# function to find the median cost
def medianValue (List) :
# find the length of the list
length=len (List)
# find middle item of the list
middleItem-length//2
# if length is even
if length%2==0:
# return the median cost
return (List [middleItem] +List [middleItem-l])/2
# if length is odd
anTRAURTRa
else:
#return the median cost
return List [middleItem]
#function to find the average cost
def average (List) :
#find the length of the list
length=len (List)
#calculate the total cost
totalCost=sum (List)
#return the average cost
return totalCost/length
#main function
def main () :
#create an empty list
costList=[
#prompt user to enter house cost
cost=int (input ('Enter the cost of one home or -99 to quit:') )
while (cost!=-99) :
#add element in the list
CostList.append (cost)
#prompt user to enter the house cost
COst=int
cost=int (input ('Enter the cost of one home or --99 to quit:'))
#display statement
print ("******
#display statement
print ("Prices of homes in your area:")
********")
#call the sorting function to sort the list
sorting (costList)
#display the sorted list
print (costList)
#display statement
print ("**k*******
#call and display the median cost
print ("The median value is $", medianValue (costList))
#call and display the average cost
print ("The average sale price is $", average (costList) )
******")
#display the minimum cost
print ("The minimum sale price is $", min (costList))
#display the maximum cost
print ("The maximum sale price is $", max (costList))
#calling main function
main ()
Transcribed Image Text:#!/usr/bin/env python3 # This program uses input from the user to calculate the median, average, minimum, and maximum sale prices of a group of homes # display welcome message print ("Real Estate Values") print () # function to sort the list def sorting (List) : #return the sorted list return List.sort () # function to find the median cost def medianValue (List) : # find the length of the list length=len (List) # find middle item of the list middleItem-length//2 # if length is even if length%2==0: # return the median cost return (List [middleItem] +List [middleItem-l])/2 # if length is odd anTRAURTRa else: #return the median cost return List [middleItem] #function to find the average cost def average (List) : #find the length of the list length=len (List) #calculate the total cost totalCost=sum (List) #return the average cost return totalCost/length #main function def main () : #create an empty list costList=[ #prompt user to enter house cost cost=int (input ('Enter the cost of one home or -99 to quit:') ) while (cost!=-99) : #add element in the list CostList.append (cost) #prompt user to enter the house cost COst=int cost=int (input ('Enter the cost of one home or --99 to quit:')) #display statement print ("****** #display statement print ("Prices of homes in your area:") ********") #call the sorting function to sort the list sorting (costList) #display the sorted list print (costList) #display statement print ("**k******* #call and display the median cost print ("The median value is $", medianValue (costList)) #call and display the average cost print ("The average sale price is $", average (costList) ) ******") #display the minimum cost print ("The minimum sale price is $", min (costList)) #display the maximum cost print ("The maximum sale price is $", max (costList)) #calling main function main ()
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Operators
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education