Skip to content

Commit 41a6196

Browse files
committed
Completed states.py
1 parent 703c25c commit 41a6196

2 files changed

Lines changed: 26 additions & 9 deletions

File tree

days/07-09-data-structures/code/Byte89.ipynb

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
{
3030
"cell_type": "code",
31-
"execution_count": 2,
31+
"execution_count": 8,
3232
"metadata": {},
3333
"outputs": [],
3434
"source": [
@@ -47,14 +47,14 @@
4747
},
4848
{
4949
"cell_type": "code",
50-
"execution_count": 25,
50+
"execution_count": 3,
5151
"metadata": {},
5252
"outputs": [
5353
{
5454
"name": "stdout",
5555
"output_type": "stream",
5656
"text": [
57-
"30.4 µs ± 563 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)\n",
57+
"20 µs ± 709 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)\n",
5858
"['Oregon', 'Massachusetts', 'Nebraska', 'Missouri', 'Alaska', 'Hawaii', 'Maryland', 'Vermont', 'South Dakota', 'Delaware']\n"
5959
]
6060
}
@@ -77,14 +77,14 @@
7777
},
7878
{
7979
"cell_type": "code",
80-
"execution_count": 26,
80+
"execution_count": 4,
8181
"metadata": {},
8282
"outputs": [
8383
{
8484
"name": "stdout",
8585
"output_type": "stream",
8686
"text": [
87-
"295 ns ± 17.2 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)\n",
87+
"149 ns ± 3.23 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n",
8888
"WI\n"
8989
]
9090
}
@@ -101,6 +101,13 @@
101101
"print(get_state_abbrev('Wisconsin'))"
102102
]
103103
},
104+
{
105+
"cell_type": "code",
106+
"execution_count": null,
107+
"metadata": {},
108+
"outputs": [],
109+
"source": []
110+
},
104111
{
105112
"cell_type": "code",
106113
"execution_count": null,
@@ -114,6 +121,18 @@
114121
"display_name": "Python 3",
115122
"language": "python",
116123
"name": "python3"
124+
},
125+
"language_info": {
126+
"codemirror_mode": {
127+
"name": "ipython",
128+
"version": 3
129+
},
130+
"file_extension": ".py",
131+
"mimetype": "text/x-python",
132+
"name": "python",
133+
"nbconvert_exporter": "python",
134+
"pygments_lexer": "ipython3",
135+
"version": "3.6.5"
117136
}
118137
},
119138
"nbformat": 4,

days/07-09-data-structures/code/states.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,15 @@ def get_state_abbrev(abbrev):
5353

5454

5555
def get_longest_state(data):
56-
"""Takes dict or list and determines the longest state name
57-
(takeaways: use a dict method to get all keys, use sorted)"""
58-
pass
56+
return max(data, key=len)
5957

6058

6159
def combine_state_names_and_abbreviations():
6260
"""Return a new list with the first 10 abbreviations from the
6361
us_state_abbrev dict ordered values and the last 10 states from
6462
the states list (takeaways: use another dict method to get all
6563
values and use sorted, list slicing and list concatenation)"""
66-
pass
64+
return sorted(us_state_abbrev.values())[:10] + sorted(states)[-10:]
6765

6866

6967
if __name__ == '__main__':

0 commit comments

Comments
 (0)