Manhattan Avenues

See the Manhattan address algorithm.

Columbus Avenue starts at 59th Street.
Addresses 1–19 are between 59th and 60th.
Addresses 20–39 are between 60th and 61st.
Addresses 40–59 are between 61st and 62nd.

Central Park West starts at 60th Street.
Addresses 1–9 are between 60th and 61st.
Addresses 10–19 are between 61st and 62nd.
Addresses 20–29 are between 62nd and 63rd.

Seventh Avenue is more complicated because it is divided into two pieces by Central Park. Seventh Avenue starts at 12th Street.
Addresses 1–19 are between 12th and 13th.
Addresses 20–39 are between 13th and 14th.
Addresses 40–59 are between 14th and 15th.
etc.
Addresses 920–939 are between 58th and 59th.
Addresses 1800–1819 are between 110th and 111th.
Addresses 1820–1839 are between 111th and 112th.
Addresses 1840–1859 are between 112th and 113th.

avenue.py

Let’s try the Empire State Building at 350 Fifth Avenue (between West 33rd and 34th Streets):

Please type the building number: 350

 0 Broadway
 1 First Avenue
 2 Second Avenue
 3 Third Avenue
 4 Fourth Avenue
 5 Fifth Avenue
 6 Sixth Avenue
 7 Seventh Avenue
 8 Eighth Avenue
 9 Ninth Avenue
10 Tenth Avenue
11 Eleventh Avenue
12 Amsterdam Avenue
13 Central Park West
14 Columbus Avenue
15 Convent Avenue
16 Edgecombe Avenue
17 Lenox Avenue
18 Lexington Avenue
19 Madison Avenue
20 Park Avenue
21 Park Avenue South
22 Riverside Drive
23 St. Nicholas Avenue
24 Vanderbilt Avenue
25 West End Avenue
26 York Avenue

Please type the avenue number: 5
350 Fifth Avenue is at 33rd Street.

Please type the building number:

A tkinter GUI with a grid of widgets

See Label, Entry, OptionMenu, Button, Text, StringVar, and the other things.

The widgets are positioned in a 3 × 3 grid. The rows of the grid are numbered from top to bottom, starting at 0. The columns of the grid are numbered from left to right, starting at 0. The Text widget that occupies row 2 spans all three columns. The last column of row 0 is empty.

Label Label
Entry OptionMenu Button
Text

The "1.0" in lines 114, 120, 124, 131, 144 means the first character on the first line of the Text widget. The 1 and 0 are the line and column numbers. See Text widget indices.

tkavenue.py

Things to try

  1. Add the four avenues in Alphabet City.
  2. Change the above lines 162–168 from
    avenueNames = []   #Start with an empty list.
    for avenue in avenues:
        avenueNames.append(avenue[0])
    
    to the following list comprehension.
    #Create a new list named avenueNames that has the same number of elements
    #as the existing list avenues.
    
    avenueNames = [avenue[0] for avenue in avenues]
    

  3. What happens if you remove the asterisk from line 172? See Calls.

  4. Does the script always output the lower of the two streets between which the address lies? If so, change the script to output both streets.
    350 Fifth Avenue is between 33rd and 34th Streets.