Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE SOLVE THIS WITH PYTHON You can find txt belove. I POST THIS QUESTIN SECOND TIME BECAUSE FIRST ANSWER WAS WRONG PLEASE DONT COPY THE

PLEASE SOLVE THIS WITH PYTHON

You can find txt belove.

I POST THIS QUESTIN SECOND TIME BECAUSE FIRST ANSWER WAS WRONG

PLEASE DONT COPY THE ANSWER BEFORE PUBLISHED

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

housePricetxt ( I cannot uploat all the data , this is just a sample):

West Ferdows Boulevard_1_True_True:73333.33 Zargandeh_2_True_True:262400.0 Feiz Garden_2_True_False:78333.33 West Ferdows Boulevard_2_True_True:83333.33 Water Organization_1_True_True:71666.67 West Ferdows Boulevard_1_True_True:71666.67 West Ferdows Boulevard_2_True_True:125000.0 West Ferdows Boulevard_2_True_True:175000.0 West Ferdows Boulevard_2_True_True:161000.0 Saadat Abad_1_True_True:113333.33 Saadat Abad_1_True_True:128333.33 Shahrake Qods_2_False_True:40000.0 ShahrAra_3_True_False:166666.67 Gisha_2_True_True:158333.33 Gisha_1_True_True:99333.33 Shahrake Gharb_3_True_False:233333.33 Ray_2_True_True:67833.33 Abbasabad_1_True_True:82000.0 Pardis_2_True_True:18000.0 Ostad Moein_2_False_True:48333.33 Farmanieh_3_True_True:333333.33 Parand_2_False_False:21166.67 Punak_1_True_False:67666.67 Punak_1_True_False:67666.67 Shahran_2_True_True:78333.33 Qasr-od-Dasht_2_True_True:100000.0 Aqdasieh_3_True_True:240000.0 Pakdasht_3_True_True:58333.33 Railway_2_True_True:110000.0 Punak_2_True_True:93333.33 Punak_2_True_False:73333.33 Punak_1_True_False:73333.33 Punak_2_True_False:73333.33 Shahran_2_True_True:116666.67 Aqdasieh_2_True_True:233333.33 Central Janatabad_1_True_True:103333.33 West Ferdows Boulevard_1_True_True:81666.67 East Ferdows Boulevard_1_True_False:64000.0 Pakdasht KhatunAbad_1_False_False:28333.33 Amirieh_2_True_True:55000.0 Amirieh_2_True_True:56666.67 Parand_3_False_True:18666.67 Punak_1_True_True:71666.67 Sattarkhan_3_True_True:183333.33 Saadat Abad_3_True_True:340000.0 Shahran_1_True_True:58666.67 Amirieh_2_True_True:56666.67 Parand_3_False_True:18666.67 Punak_1_True_True:71666.67 Sattarkhan_3_True_True:183333.33 Saadat Abad_3_True_True:340000.0 Shahran_1_True_True:58666.67 Baghestan_3_True_False:50000.0 West Ferdows Boulevard_2_True_True:124333.33 Shahrake Qods_2_False_False:20666.67 Shahryar_1_False_False:19333.33 Northern Janatabad_2_True_True:101666.67 West Ferdows Boulevard_2_True_False:66666.67 North Program Organization_2_True_True:86666.67 Daryan No_3_True_True:199666.67 North Program Organization_2_True_True:76666.67 Pirouzi_1_True_False:43333.33 Southern Program Organization_2_True_True:75666.67 Rudhen_3_True_True:133333.33 West Pars_2_True_True:133333.33 Afsarieh_2_True_True:55000.0 Marzdaran_3_True_True:223333.33 Parand_2_True_True:19333.33 Punak_1_True_True:76666.67 Shahrake Qods_1_True_True:21666.67 Dorous_2_True_True:563333.33 Shahrake Qods_0_False_False:8266.67 Pardis_2_True_True:17000.0 Shahran_2_True_True:128333.33 Sadeghieh_3_True_True:200000.0 Chahardangeh_2_False_False:26000.0 ShahrAra_3_True_True:240000.0 Parand_2_True_True:13666.67 Pakdasht_2_False_False:14333.33 Baqershahr_2_False_False:26666.67 Parand_2_True_True:18166.67 Parand_2_True_False:42666.67 Punak_2_True_True:93333.33 Gisha_3_True_True:373333.33 Parand_3_True_False:25000.0 Jeyhoon_1_False_False:28333.33 Lavizan_2_True_True:110000.0 Shams Abad_2_True_True:109333.33 Fatemi_3_True_True:160000.0 Gisha_3_True_True:243333.33 Keshavarz Boulevard_3_True_True:131666.67 Parand_2_False_True:12333.33 Baghestan_2_False_False:25000.0 Salsabil_2_True_True:57500.0 Kahrizak_2_True_True:26000.0 Shahryar_2_True_True:47300.0 Qarchak_2_True_False:40000.0 Northren Jamalzadeh_2_True_True:120000.0 Salsabil_1_True_False:35000.0

Description You are given a file named "houseprices.txt", which stores the prices of houses in Iran. Your task is to develop a Python program that displays the most expensive 5 neighborhoods for the house specification that the user has provided. In your program, the user will provide two inputs for the number of rooms and the availability of a parking spot. By using provided specifications (room number and parking spot), you are supposed to find the average house price that matches requests for each address, and then print the most expensive 5 neighborhoods (addresses) based on these average values. The user may choose one or more specifications (room number and parking spot) as "any" which means all choices for that spec will be taken into consideration. If there are no houses that match specification, then the program should inform the user regarding unavailability. Please see the "Sample Runs" section in order to understand the flow of the program, the inputs and the outputs in a better way. Input File You will be given only one input file sample. The name of this input file will be housePrices.txt. Each line of the input file will contain 5 pieces of information in the following format: Address_Room_Parking_Elevator:Price(USD) Ex: Shahran_1_True_True: 61666.67 - As we said, there are 5 pieces of information on each line for a specific house: neighborhood name, number of rooms, has a parking spot or not, has an elevator or not and price of the house, respectively. Each piece of information is separated with an underline ("-") except price of the house. It is separated with a column (":"). - The example given above represents a house that is located on Shahran that has a parking spot, elevator and has exactly 1 room with a price of $6166.67. - You can assume that the file information will be given in the correct format. Thus, you don't have to perform any format check on the file content. - You can assume that there are no duplications inside of the file. - You can assume that there will be no empty lines in the file. However, you cannot make any assumptions on the number of lines of this file. Keep this in mind while you're preprocessing the content of the file. Input and Output The inputs of the program and their order are explained below. It is extremely important to follow this order since we automatically process your programs. Thus your work will be graded as 0 unless the order is entirely correct. Please see the "Sample Runs" section for some examples. The prompts of the input statements to be used has to be exactly the same as the prompts of the "Sample Runs". - Do not change the file name. It should be "houseprices.txt". While trying your code on CodeRunner, do not provide any path to open the file. You just need to execute the following command: open ("housePrices.txt") - Your program should display the following prompt to get the asked number of room input from the user. Enter the room number: - If the user enters an invalid input, then your program should keep asking till a valid one is entered. The valid inputs are nonnegative integers or "any" string. - If "any" is entered, all existing room numbers should be taken into consideration. - Keep in mind that "any" is case insensitive which means "aNy" or "any" or "ANY" or "ANy" need to be considered as the same valid input. - Your program should display the following prompt to get the if parking spot is necessary or not from the user. Enter parking option: - If the user enters an invalid parking spot option, then your program should keep asking till a valid one is entered. - For the parking option, the user may enter either "True" or "False" or "any". If "any" is entered, all existing options ("True" and "False") should be taken into consideration. - Keep in mind that, "True", "False" and "any" are case insensitive which means "any"-"ANY" or "True"-"TrUE" or "False"-"fALSE" need to be considered as the same valid input. - When inputs are taken, your program will find the average house price for each address for given specifications. After you calculate the average house price for each address, you should only display the most expensive 5 addresses based on their average prices. You should display the results exactly in the same format: - There should be a horizontal tab character ("\t") between the address name and the average price value. Additionally, the price values should be printed with 2 decimal places. - MostExpensiveAdressname1 is the most expensive address name while MostexpensiveAdressName 5 is the most expensive fifth address name. - If there are less than 5 addresses (but at least 1) which satisfies the given criterias, then you should print them all in the correct order. - You may assume that the average house prices for each address will be different from each other. - If there are no houses that matches the asked specifications, display the following output: No results for these options Sample Runs Below, we provide some sample runs of the program that you will develop. The italic and bold phrases are inputs taken from the user. You have to display the required information in the same order and with the same words and characters as below. Sample Run 1 Enter the room number: 2 Enter parking option: True Zaferanieh 539444.44 Velenjak 415833.33 Dezashib 375000.00 Niavaran 353622.81 Araj 350000.00 Sample Run 2 Enter the room number: 3 Enter parking option: False Lavasan 900000.00 Velenjak 523333.33 Araj 446666.67 Gheitarieh 416666.67 Farmanieh 230000.00 Sample Run 3 Enter the room number: any Enter parking option: any Gandhi 2333333.33 Lavasan 1600000.00 Mahmoudieh 1115555.56 Vanak 1090000.00 Elahieh 892878.43 Sample Run 4 Enter the room number: an Enter the room number: anny Enter the room number: AnY Enter parking option: any Gandhi 2333333.33 Lavasan 1600000.00 Mahmoudieh 1115555.56 Vanak 1090000.00 Elahieh 892878.43 Sample Run 5 Enter the room number: 5 Enter parking option: True Abazar 3033333.33 Zafar 2666666.67 Mahmoudieh 2500000.00 Gandhi 2333333.33 Vanak 1916666.67 Sample Run 6 Enter the room number: 6 Enter parking option: any No result for these options Description You are given a file named "houseprices.txt", which stores the prices of houses in Iran. Your task is to develop a Python program that displays the most expensive 5 neighborhoods for the house specification that the user has provided. In your program, the user will provide two inputs for the number of rooms and the availability of a parking spot. By using provided specifications (room number and parking spot), you are supposed to find the average house price that matches requests for each address, and then print the most expensive 5 neighborhoods (addresses) based on these average values. The user may choose one or more specifications (room number and parking spot) as "any" which means all choices for that spec will be taken into consideration. If there are no houses that match specification, then the program should inform the user regarding unavailability. Please see the "Sample Runs" section in order to understand the flow of the program, the inputs and the outputs in a better way. Input File You will be given only one input file sample. The name of this input file will be housePrices.txt. Each line of the input file will contain 5 pieces of information in the following format: Address_Room_Parking_Elevator:Price(USD) Ex: Shahran_1_True_True: 61666.67 - As we said, there are 5 pieces of information on each line for a specific house: neighborhood name, number of rooms, has a parking spot or not, has an elevator or not and price of the house, respectively. Each piece of information is separated with an underline ("-") except price of the house. It is separated with a column (":"). - The example given above represents a house that is located on Shahran that has a parking spot, elevator and has exactly 1 room with a price of $6166.67. - You can assume that the file information will be given in the correct format. Thus, you don't have to perform any format check on the file content. - You can assume that there are no duplications inside of the file. - You can assume that there will be no empty lines in the file. However, you cannot make any assumptions on the number of lines of this file. Keep this in mind while you're preprocessing the content of the file. Input and Output The inputs of the program and their order are explained below. It is extremely important to follow this order since we automatically process your programs. Thus your work will be graded as 0 unless the order is entirely correct. Please see the "Sample Runs" section for some examples. The prompts of the input statements to be used has to be exactly the same as the prompts of the "Sample Runs". - Do not change the file name. It should be "houseprices.txt". While trying your code on CodeRunner, do not provide any path to open the file. You just need to execute the following command: open ("housePrices.txt") - Your program should display the following prompt to get the asked number of room input from the user. Enter the room number: - If the user enters an invalid input, then your program should keep asking till a valid one is entered. The valid inputs are nonnegative integers or "any" string. - If "any" is entered, all existing room numbers should be taken into consideration. - Keep in mind that "any" is case insensitive which means "aNy" or "any" or "ANY" or "ANy" need to be considered as the same valid input. - Your program should display the following prompt to get the if parking spot is necessary or not from the user. Enter parking option: - If the user enters an invalid parking spot option, then your program should keep asking till a valid one is entered. - For the parking option, the user may enter either "True" or "False" or "any". If "any" is entered, all existing options ("True" and "False") should be taken into consideration. - Keep in mind that, "True", "False" and "any" are case insensitive which means "any"-"ANY" or "True"-"TrUE" or "False"-"fALSE" need to be considered as the same valid input. - When inputs are taken, your program will find the average house price for each address for given specifications. After you calculate the average house price for each address, you should only display the most expensive 5 addresses based on their average prices. You should display the results exactly in the same format: - There should be a horizontal tab character ("\t") between the address name and the average price value. Additionally, the price values should be printed with 2 decimal places. - MostExpensiveAdressname1 is the most expensive address name while MostexpensiveAdressName 5 is the most expensive fifth address name. - If there are less than 5 addresses (but at least 1) which satisfies the given criterias, then you should print them all in the correct order. - You may assume that the average house prices for each address will be different from each other. - If there are no houses that matches the asked specifications, display the following output: No results for these options Sample Runs Below, we provide some sample runs of the program that you will develop. The italic and bold phrases are inputs taken from the user. You have to display the required information in the same order and with the same words and characters as below. Sample Run 1 Enter the room number: 2 Enter parking option: True Zaferanieh 539444.44 Velenjak 415833.33 Dezashib 375000.00 Niavaran 353622.81 Araj 350000.00 Sample Run 2 Enter the room number: 3 Enter parking option: False Lavasan 900000.00 Velenjak 523333.33 Araj 446666.67 Gheitarieh 416666.67 Farmanieh 230000.00 Sample Run 3 Enter the room number: any Enter parking option: any Gandhi 2333333.33 Lavasan 1600000.00 Mahmoudieh 1115555.56 Vanak 1090000.00 Elahieh 892878.43 Sample Run 4 Enter the room number: an Enter the room number: anny Enter the room number: AnY Enter parking option: any Gandhi 2333333.33 Lavasan 1600000.00 Mahmoudieh 1115555.56 Vanak 1090000.00 Elahieh 892878.43 Sample Run 5 Enter the room number: 5 Enter parking option: True Abazar 3033333.33 Zafar 2666666.67 Mahmoudieh 2500000.00 Gandhi 2333333.33 Vanak 1916666.67 Sample Run 6 Enter the room number: 6 Enter parking option: any No result for these options

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting For Managers Text And Cases

Authors: William J. Bruns

3rd Edition

0324291213, 978-0324291216

More Books

Students also viewed these Accounting questions

Question

Explain the concept of shear force and bending moment in beams.

Answered: 1 week ago