There are a set of schools and houses in a city. You need to group the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
There are a set of schools and houses in a city. You need to group the houses into school zones. The zone for each school is defined as a circle with a 3km radius. That means, any house that has a radial distance less than or equal to 3km from the school is considered to be in the school zone. y). See the The location of each school and each house is specified using their coordinates, (x,y). See the below map as an example (not to scale). x S(1.5,7) x H7(0.5,6.8) XH6(4,8) x H (12,6.5) x H(8,7.5) X S3 (10,5) X H3(1,2) x S(1,1) x H(0.5,0.3) x H5(3,6) x H,(9,4.5) X H(9.5,1) The list of tuples schools contains the locations (coordinates) of the schools. The list of tuples houses contains the locations (coordinates) of the houses. You will be solving this problem in 3 steps as outlined in the 3 sub-parts of this question below. Note: The above map is just an example. Your codes should work for any map with the same format. Make sure you reuse any functions written in the previous parts (of this question) wherever possible, without re-writing the same code. 20a) Write a function that takes in the coordinates of two points and returns the Euclidean distance between them (rounded to 2 decimal places). The Euclidean distance, D, is calculated using the following formula: D = (x1 = x2)+(y1 - y2) - where (X1,Y1) and (x2,Y2) are the coordinates of the two points. (2 marks) def distance(point1,point2): Inputs: Two tuples containing the coordinates of two points Output: The Euclidean distance between the two points, rounded to 2 decimal places Examples: >>> distance((1,3),(2,4)) 1.41 >>> distance((0,5),(2.5)) 2.0 >>> distance((0,0), (3,4)) 5.0 20b) Write a function that returns True if the distance between two points is less than or equal to 3 units. This function can be used to determine if a given house is within the zone of a given school. Make sure you reuse the code written in part (a) above. (4 marks) def within_zone(point1.point2): Inputs: Two tuples containing the coordinates of two points Output: True if the distance between two points is less than or equal to 3 units, False otherwise Examples: >>> within_zone((1,3),(2,4)). True >>> within_zone((0,0), (3,4)) False >>> within_zone((2.5,6.3),(4,7.2)) True 20c) Write a function that will group the houses within each school zone based on the following criteria. For each school create a list of houses within its zone (within 3km). If a house is within 3km from more than one school add that house to the lists of all those schools. If a house does not fall within 3km of any of the schools, that house needs to be added to the list of the nearest school. Your function needs to take in two lists of tuples, one containing the locations of the schools and the other containing the locations of the houses. The output from the function should be a table, with each row corresponding to each school and the inner lists containing the house locations (tuples) that are within the zone for each school. For example, in your output table, row 0 contains the locations of houses that are within the zone for school 0, row 1 contains the locations of houses that are within the zone for school 1 and so on. rmat of t (4marks) Refer to the examples below (in doctests) for the format of the output. (4 marks) er to the examples below (in doctests) for the f def group_zones(schools,houses): Inputs: Two lists of tuples containing the locations (coordinates) of schools and houses. Output: A table contaning the list of houses that belong to each school zone. Examples: >>> schools = [(1,1),(1.5,7),(10,5)] >>> houses = [(0.5,0.3),(8,7.5), (1,2).(9.5,1),(3,6),(4,8). (0.5,6.8),(12,6.5),(9,4.5)] >>>group_zones(schools, houses) [[(0.5, 0.3), (1, 2)]. [(3, 6), (4, 8), (0.5, 6.8)]. [(12, 6.5), (9,4.5), (8, 7.5), (9.5, 1)]] >>> schools = [(0,0),(2,2)] >>> houses = [(1,0.5),(1,3.5),(0.2,1.5)] >>> group_zones (schools, houses) [[(1,0.5), (0.2, 1.5)], [(1,0.5), (1, 3.5), (0.2, 1.5)]] There are a set of schools and houses in a city. You need to group the houses into school zones. The zone for each school is defined as a circle with a 3km radius. That means, any house that has a radial distance less than or equal to 3km from the school is considered to be in the school zone. y). See the The location of each school and each house is specified using their coordinates, (x,y). See the below map as an example (not to scale). x S(1.5,7) x H7(0.5,6.8) XH6(4,8) x H (12,6.5) x H(8,7.5) X S3 (10,5) X H3(1,2) x S(1,1) x H(0.5,0.3) x H5(3,6) x H,(9,4.5) X H(9.5,1) The list of tuples schools contains the locations (coordinates) of the schools. The list of tuples houses contains the locations (coordinates) of the houses. You will be solving this problem in 3 steps as outlined in the 3 sub-parts of this question below. Note: The above map is just an example. Your codes should work for any map with the same format. Make sure you reuse any functions written in the previous parts (of this question) wherever possible, without re-writing the same code. 20a) Write a function that takes in the coordinates of two points and returns the Euclidean distance between them (rounded to 2 decimal places). The Euclidean distance, D, is calculated using the following formula: D = (x1 = x2)+(y1 - y2) - where (X1,Y1) and (x2,Y2) are the coordinates of the two points. (2 marks) def distance(point1,point2): Inputs: Two tuples containing the coordinates of two points Output: The Euclidean distance between the two points, rounded to 2 decimal places Examples: >>> distance((1,3),(2,4)) 1.41 >>> distance((0,5),(2.5)) 2.0 >>> distance((0,0), (3,4)) 5.0 20b) Write a function that returns True if the distance between two points is less than or equal to 3 units. This function can be used to determine if a given house is within the zone of a given school. Make sure you reuse the code written in part (a) above. (4 marks) def within_zone(point1.point2): Inputs: Two tuples containing the coordinates of two points Output: True if the distance between two points is less than or equal to 3 units, False otherwise Examples: >>> within_zone((1,3),(2,4)). True >>> within_zone((0,0), (3,4)) False >>> within_zone((2.5,6.3),(4,7.2)) True 20c) Write a function that will group the houses within each school zone based on the following criteria. For each school create a list of houses within its zone (within 3km). If a house is within 3km from more than one school add that house to the lists of all those schools. If a house does not fall within 3km of any of the schools, that house needs to be added to the list of the nearest school. Your function needs to take in two lists of tuples, one containing the locations of the schools and the other containing the locations of the houses. The output from the function should be a table, with each row corresponding to each school and the inner lists containing the house locations (tuples) that are within the zone for each school. For example, in your output table, row 0 contains the locations of houses that are within the zone for school 0, row 1 contains the locations of houses that are within the zone for school 1 and so on. rmat of t (4marks) Refer to the examples below (in doctests) for the format of the output. (4 marks) er to the examples below (in doctests) for the f def group_zones(schools,houses): Inputs: Two lists of tuples containing the locations (coordinates) of schools and houses. Output: A table contaning the list of houses that belong to each school zone. Examples: >>> schools = [(1,1),(1.5,7),(10,5)] >>> houses = [(0.5,0.3),(8,7.5), (1,2).(9.5,1),(3,6),(4,8). (0.5,6.8),(12,6.5),(9,4.5)] >>>group_zones(schools, houses) [[(0.5, 0.3), (1, 2)]. [(3, 6), (4, 8), (0.5, 6.8)]. [(12, 6.5), (9,4.5), (8, 7.5), (9.5, 1)]] >>> schools = [(0,0),(2,2)] >>> houses = [(1,0.5),(1,3.5),(0.2,1.5)] >>> group_zones (schools, houses) [[(1,0.5), (0.2, 1.5)], [(1,0.5), (1, 3.5), (0.2, 1.5)]]
Expert Answer:
Related Book For
An Introduction To Statistical Methods And Data Analysis
ISBN: 9781305465527
7th Edition
Authors: R. Lyman Ott, Micheal T. Longnecker
Posted Date:
Students also viewed these operating system questions
-
/** * WEB222 - Assignment 02 * * I declare that this assignment is my own work in accordance with * Seneca Academic Policy. No part of this assignment has been * copied manually or electronically...
-
DON'T SUMMARIZE JUST PARAGRAPH OF WHAT YOU THOUGHT/LEARNED CHAPTER 13 - The phrase "garbage in, garbage out" highlights the importance of input controls. If the data entered into a system are...
-
On December 31, 2019, Metlock Inc. borrowed $3,300,000 at 13% payable annually to finance the construction of a new building. In 2020, the company made the following expenditures related to this...
-
An increase in the market price of men's haircuts, from $15 per haircut to $25 per haircut, initially causes a local barbershop to have its employees work overtime to increase the number of daily...
-
Graph the system of linear inequalities and indicate the solution set. 3x - 2y 6 x - y 3
-
Gilead is a large drug producer, with a majority of its prescription drug product sales occurring in the United States. Gilead produces anti-HIV drug therapies, including the drugs Atripla, Truvada,...
-
Patterson Awning manufactures awnings and uses a standard cost system. The company allocates overhead based on the number of direct labor hours. The following are the companys cost and standards...
-
7. 5 What is 11. as an improper fraction? 16 Answer: 17 9 - 8. Which is the difference of 32 32 in lowest terms? 9 18 1 8 32 1 9. 8 5 3 + Which is the quotient of 12 10? 1 18 1 10. What is 25 as a...
-
INSTRUCTION(S): 1. Closed/Opened book examination: Opened book 2. Submitted your project as a PDF file or image file 3. The file name is as follows: Student name_Student number_Course code (Example:...
-
What does this tell you about the relationship between capital structure and shareholder risk? How is the shareholders required return on equity affected? Explain.
-
Simulate the processing of the program in Problem 10-12 using the RISC CPU with data-hazard stall in Figure 10-12. Give the contents of each pipeline platform and the register file (the latter only...
-
Heineken NV has decided to borrow money by issuing perpetual bonds with a coupon rate of 6 per cent, payable annually. The one-year interest rate is 6 per cent. Next year, there is a 35 per cent...
-
Despite the significant costs of high leverage, tax systems around the world have a built-in debt bias. Why do you think this is?
-
Tvep plc issued convertible bonds with a conversion price of 20. The bonds are available for immediate conversion. The current price of the companys equity is 18 per share. The current market price...
-
In 2014 XYZ Co. had sales of $74 billion and a net income of $23 billion, and its year-end total assets were $200 billion. The firm's total-debt-to-total-assets ratio was 45.3%. What was XYZ Co.s ROE...
-
F.(3e* -2x 3 sin(2x)) is equal to 2 3 Cos 8. IT 3, t (4+@ 2 3, 1+o 1 4 Cos 4 4 1 3. 1 +4cos V7 (1+o 4 1 4 Cos 4 1+0 4-
-
Refer to Exercise 17.22. a. If the five investigators are considered to be a fixed effect, what are the hypotheses being tested, and what conclusions can be drawn if the null hypothesis is rejected?...
-
Effective tax rates (per $ 100) on residential property for three groups of large cities, ranked by residential property tax rate, are shown in the following table. a. Compute the mean, median, and...
-
Refer to the study described in Exercise 14.11. a. Use Tukeys W procedure to identify significant differences in the mean sensory ratings of the three levels of percentage of milk fat. b. Use Tukeys...
-
You are managing the development of a case tracking system project for your large law firm. The requirements phase of the project is almost complete, and preliminary design work has begun. The...
-
At the conclusion of this chapter, the textbook mentions that data and process modeling may eventually become obsolete due to the increasing popularity and usage of object-oriented modeling and...
-
Although data and process models depict the same system with different views, systemi designers must synchronize these different views to make sure that their models are consistent and complete. One...
Study smarter with the SolutionInn App