#Test 2 Spring 2017 Wed March 1 #Program 1 (90 points): #The person would like to buy the house but has a #limited budget. #The program will read budget limit, number of cities to look for the #house and the number of houses in each city. #Assume, that it will be the same amount of houses in each city. #The program will generate the integer price for each house, in $1000 #All prices will be stored in 2-D list. One row of 2-D list stores prices #for one city. #In addition, the program will generate the integer repair price for each #house, in $1000. #All repair prices will be stored in 2-D list. One row of 2-D list stores #repair prices for one city. #The program will also create 1D list of city names #The person would be able to purchase the house if the total price (sale price plus repair price) #equal or below the budget limit #THE PROGRAM MUST DO THE FOLLOWING: #1. Create a 2D list with total prices for each house (sale price + repair price) - write function total to perform this task #2. Count the number of suitable houses in each city and store the results in 1D list - write function count_house to perform this task #PROGRAM OUTPUT: #1. 2d list of total prices #2. The number of suitable houses in each city. PRINT NAME OF THE CITY ALONG WITH NUMBER OF HOUSES #The program is partially written for you. Complete the program #Program 2: (10 points) Continue the program above to create a 2d list of #prices of suitable houses in each city. Pay attention, this 2d list #might have various number of items in each row so you cannot print it in #the table format. #Example - pay attention all data is in $1000 (for example, price 50 means $50,000: #budget: 50 #2 cities 4 houses #city_names={"chester", "philadelphia"} #sale prices: #50 25 16 7 #67 45 23 72 #repair prices: #12 23 11 23 #1 5 4 4 #Output: #total prices #62 48 27 30 #68 50 27 76 #counters: #[3, 2] #can buy 3 houses in chester and 2 houses in philadelphia #for the second part the output: #[[48, 27, 30], [50, 27]] import random def make_2d_list(row, col, min, max): a = [[ 0 for i in range(col)] for j in range(row)] for i in range(row): for j in range(col): a[i][j]=random.randint(min, max) return a def print_table(my_list_2d, row, col): for i in range(row): print(my_list_2d[i]) def make_list_string(size): my_list=[] print("enter", size, "strings") for i in range(size): word= input("") my_list.append(word) return my_list #complete the following functions def main(): #complete the program to find: #1. 2d list of total prices #2. 1d list of counters (number of suitable houses in each city budget=int(input("enter budget limit ")) row=int(input("enter number of cities ")) col=int(input("enter number of houses in each city ")) sale_price=make_2d_list(row, col, 1, 100) print("sale prices are ") print_table(sale_price, row, col) repair_price=make_2d_list(row, col, 1, 25) print("repair prices are ") print_table(repair_price, row, col) city_names= make_list_string(row) print("city names") print(city_names) #complete the program main()