Area codes

US telephone area codes are allocated somewhat randomly. There was a deliberate effort to keep geographical proximity from corresponding to numerical proximity, unlike zip codes. (More of zip code proximity here.) In particular, consecutive area codes should belong to different states. The thought was that this would reduce errors.

It’s still mostly the case that states do not have consecutive area codes. But there is one exception: Colorado contains area codes 719 and 720. California, Texas, and New York all have a pair of area codes that differ by 2. For example, Tyler has area code 430 and Midland has area code 432. The median minimum difference between area codes within a state is 19.

I don’t know why this is. Only about 400 of the possible 1000 area codes are assigned to a geographic region. (Some are reserved for non-geographic uses, like toll-free numbers.) There’s no need to assign consecutive area codes within a state when adding a new area code.

I wrote a little script to look up the location corresponding to an area code. This is something I have to do fairly often in order to tell what time zone a client is probably in.

I debated whether to write such a script because it’s trivial to search for such information. Typing “area code 510” into a search bar is no harder than typing areacode 510 on the command line, but the latter is less disruptive to my workflow. I don’t have to click on any sketchy websites filled with adds, I’m not tempted to go anywhere else while my browser is open, and the script works when my internet connection is down.

The script is trivial:

    #!/usr/bin/env python3
    import sys

    codes = {
        "202" : "District of Columbia",
        "203" : "Bridgeport, CT",
        "204" : "Manitoba", 
        ....
        "985" : "Houma, LA",
        "986" : "Idaho",
        "989" : "Saginaw, MI",
    }

    area = sys.argv[1]
    print(codes[area]) if area in codes else print("Unassigned")

If you’d like, you can grab the full script here.

7 thoughts on “Area codes

  1. I believe the original area codes were allocated by population to minimize dialing time (back when dialing a 3 took less time than dialing 9). That’s how NYC got 212, Chicago 312, LA 412 and so on.

    I never understood the methodology employed when fax numbers, then cell phones caused all the area code expansions.

  2. Either you have a very good sense of what time zone states are in, or I have a prediction for one of the features for version 2.0 of this script.

  3. I have a good enough sense for states and time zones most of the time, but that would be a useful extension.

  4. It seems like the concern about similar area codes should be how easy it is to enter the wrong area code, rather than just concern about consecutive numbers. So 719 and 720 are much more different than 719 and 819, or 719 and 710.

Comments are closed.