{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2496435"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Dictionaries does associations\n",
    "# Assigns county names to population numbers\n",
    "# Here's how you do these associations \n",
    "county_census_pop_2010 = {\"Brevard\":543376, \"Broward\":1748066, \"Collier\":321520, \n",
    "                   \"Hillsborough\":1229226, \"Miami-Dade\":2496435, \"Monroe\":73090, \n",
    "                   \"Palm Beach\":1320134, \"Pinellas\":916542}\n",
    "county_census_pop_2010['Miami-Dade']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1748066"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "county_census_pop_2010['Broward']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'Polk'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-3-731a13b135f4>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mcounty_census_pop_2010\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Polk'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mKeyError\u001b[0m: 'Polk'"
     ]
    }
   ],
   "source": [
    "county_census_pop_2010['Polk']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "602095"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "county_census_pop_2010['Polk'] = 602095\n",
    "county_census_pop_2010['Duval'] = 864263\n",
    "county_census_pop_2010['Polk']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Brevard': 543376,\n",
       " 'Broward': 1748066,\n",
       " 'Collier': 321520,\n",
       " 'Hillsborough': 1229226,\n",
       " 'Miami-Dade': 2496435,\n",
       " 'Monroe': 73090,\n",
       " 'Palm Beach': 1320134,\n",
       " 'Pinellas': 916542,\n",
       " 'Polk': 602095,\n",
       " 'Duval': 864263}"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "county_census_pop_2010"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "county_area = {} # an empty dictionary\n",
    "county_area"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(county_census_pop_2010)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'Polk' in county_census_pop_2010"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "morse = {\n",
    "\"A\" : \".-\", \n",
    "\"B\" : \"-...\", \n",
    "\"C\" : \"-.-.\", \n",
    "\"D\" : \"-..\", \n",
    "\"E\" : \".\", \n",
    "\"F\" : \"..-.\", \n",
    "\"G\" : \"--.\", \n",
    "\"H\" : \"....\", \n",
    "\"I\" : \"..\", \n",
    "\"J\" : \".---\", \n",
    "\"K\" : \"-.-\", \n",
    "\"L\" : \".-..\", \n",
    "\"M\" : \"--\", \n",
    "\"N\" : \"-.\", \n",
    "\"O\" : \"---\", \n",
    "\"P\" : \".--.\", \n",
    "\"Q\" : \"--.-\", \n",
    "\"R\" : \".-.\", \n",
    "\"S\" : \"...\", \n",
    "\"T\" : \"-\", \n",
    "\"U\" : \"..-\", \n",
    "\"V\" : \"...-\", \n",
    "\"W\" : \".--\", \n",
    "\"X\" : \"-..-\", \n",
    "\"Y\" : \"-.--\", \n",
    "\"Z\" : \"--..\", \n",
    "\"0\" : \"-----\", \n",
    "\"1\" : \".----\", \n",
    "\"2\" : \"..---\", \n",
    "\"3\" : \"...--\", \n",
    "\"4\" : \"....-\", \n",
    "\"5\" : \".....\", \n",
    "\"6\" : \"-....\", \n",
    "\"7\" : \"--...\", \n",
    "\"8\" : \"---..\", \n",
    "\"9\" : \"----.\", \n",
    "\".\" : \".-.-.-\", \n",
    "\",\" : \"--..--\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "38"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(morse)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Brevard\n",
      "Broward\n",
      "Collier\n",
      "Hillsborough\n",
      "Miami-Dade\n",
      "Monroe\n",
      "Palm Beach\n",
      "Pinellas\n",
      "Polk\n",
      "Duval\n"
     ]
    }
   ],
   "source": [
    "for key in county_census_pop_2010.keys(): \n",
    "    print(key)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "543376\n",
      "1748066\n",
      "321520\n",
      "1229226\n",
      "2496435\n",
      "73090\n",
      "1320134\n",
      "916542\n",
      "602095\n",
      "864263\n"
     ]
    }
   ],
   "source": [
    "for value in county_census_pop_2010.values():\n",
    "    print(value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Brevard\t543376\n",
      "Broward\t1748066\n",
      "Collier\t321520\n",
      "Hillsborough\t1229226\n",
      "Miami-Dade\t2496435\n",
      "Monroe\t73090\n",
      "Palm Beach\t1320134\n",
      "Pinellas\t916542\n",
      "Polk\t602095\n",
      "Duval\t864263\n"
     ]
    }
   ],
   "source": [
    "for key in county_census_pop_2010.keys(): \n",
    "    print(key + \"\\t\" + str(county_census_pop_2010[key]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Brevard\t543376\n",
      "Broward\t1748066\n",
      "Collier\t321520\n",
      "Hillsborough\t1229226\n",
      "Miami-Dade\t2496435\n",
      "Monroe\t73090\n",
      "Palm Beach\t1320134\n",
      "Pinellas\t916542\n",
      "Polk\t602095\n",
      "Duval\t864263\n"
     ]
    }
   ],
   "source": [
    "# Doing it differently\n",
    "for key, value in county_census_pop_2010.items(): \n",
    "    print(key + \"\\t\" + str(value))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "What is the population of Brevard county? 543376.\n",
      "What is the population of Broward county? 1748066.\n",
      "What is the population of Collier county? 321520.\n",
      "What is the population of Hillsborough county? 1229226.\n",
      "What is the population of Miami-Dade county? 2496435.\n",
      "What is the population of Monroe county? 73090.\n",
      "What is the population of Palm Beach county? 1320134.\n",
      "What is the population of Pinellas county? 916542.\n"
     ]
    }
   ],
   "source": [
    "# The zip operation\n",
    "# Takes 2 lists and zips them into a dictionary\n",
    "# Uses one as a key and the other as values\n",
    "counties = [\"Brevard\", \"Broward\", \"Collier\", \n",
    "                   \"Hillsborough\", \"Miami-Dade\", \"Monroe\", \n",
    "                   \"Palm Beach\", \"Pinellas\"]\n",
    "pop = [543376, 1748066, 321520, \n",
    "                   1229226, 2496435, 73090, \n",
    "                   1320134, 916542]\n",
    "# Sizes of above lists should be same\n",
    "for c, p in zip(counties, pop):\n",
    "    print('What is the population of {0} county? {1}.'.format(c, p))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Population and Area of Brevard county are 543376 and 1018 sq miles.\n",
      "Population and Area of Broward county are 1748066 and 1209 sq miles.\n",
      "Population and Area of Collier county are 321520 and 2026 sq miles.\n",
      "Population and Area of Hillsborough county are 1229226 and 1051 sq miles.\n",
      "Population and Area of Miami-Dade county are 2496435 and 1946 sq miles.\n",
      "Population and Area of Monroe county are 73090 and 997 sq miles.\n",
      "Population and Area of Palm Beach county are 1320134 and 2034 sq miles.\n",
      "Population and Area of Pinellas county are 916542 and 280 sq miles.\n"
     ]
    }
   ],
   "source": [
    "area = [1018, 1209, 2026, 1051, 1946, 997, 2034, 280]\n",
    "for c, p , a in zip(counties, pop, area):\n",
    "    print('Population and Area of {0} county are {1} and {2} sq miles.'.format(c, p, a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
