#!/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 ()
Operations
In mathematics and computer science, an operation is an event that is carried out to satisfy a given task. Basic operations of a computer system are input, processing, output, storage, and control.
Basic Operators
An operator is a symbol that indicates an operation to be performed. We are familiar with operators in mathematics; operators used in computer programming are—in many ways—similar to mathematical operators.
Division Operator
We all learnt about division—and the division operator—in school. You probably know of both these symbols as representing division:
Modulus Operator
Modulus can be represented either as (mod or modulo) in computing operation. Modulus comes under arithmetic operations. Any number or variable which produces absolute value is modulus functionality. Magnitude of any function is totally changed by modulo operator as it changes even negative value to positive.
Operators
In the realm of programming, operators refer to the symbols that perform some function. They are tasked with instructing the compiler on the type of action that needs to be performed on the values passed as operands. Operators can be used in mathematical formulas and equations. In programming languages like Python, C, and Java, a variety of operators are defined.
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?
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images