Assignment 8 — multi-input problem solving
Due Friday, September 14, extended to Monday, September 17
- The program takes as its integer input, the street and avenue of one corner in Manhattan and the street and avenue of another corner in Manhattan. The program then computes an estimate of the distance between the two locations using the above formula. The only program output besides the prompts is the estimate.
- Note: the program is to make only two prompts for data, each with two inputs on a single line, as demonstrated in the sample runs below.
- New Yorkers approximate distance between two Manhattan locations using the number of streets and avenues separating the starting and ending locations.
- The approximation uses the following estimates.
- The distance of a Manhattan city block running from one street to the next street is on average 1/20th of a mile.
- The distance of a Manhattan city block running from one avenue to the next avenue is on average 3/20th of mile.
- Based on these block length estimates, the distance from the corner at street s1 and avenue a1 to the corner of street s2 and avenue a2 is
( 0.05 × | s1 – s2 | ) + ( 0.15 × | a1 – a2 | )
- If you do not remember | |’s from high school algebra, | s1 – s2 | is the absolute value of s1 – s2 and | a1 – a2 | is the absolute value of a1 – a2.
- Python built-in function abs() computes absolute values. It is important to calculate the absolute values of the street differences and avenue differences separately.
- Because both input prompts should cause the user to supply two values, string function
split()should prove helpful. See string documentation for information on
split()or the post-class
Two different sample runs
Starting corner (street and avenue): 59 6
Ending corner (street and avenue): 34 7
Starting corner (street and avenue): 47 2
Ending corner (street and avenue): 238 6