Article 6E96B Area codes

Area codes

by
John
from John D. Cook on (#6E96B)

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 web sites 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.

The post Area codes first appeared on John D. Cook.
External Content
Source RSS or Atom Feed
Feed Location http://feeds.feedburner.com/TheEndeavour?format=xml
Feed Title John D. Cook
Feed Link https://www.johndcook.com/blog
Reply 0 comments