Skip to content

Commit 49a99cc

Browse files
committed
final note
1 parent c480eaa commit 49a99cc

File tree

34 files changed

+6693
-195
lines changed

34 files changed

+6693
-195
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,311 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"#Advanced Functions Test \n",
8+
"\n",
9+
"### For this test, you should use the built-in functions to be able to write the requested functions in one line."
10+
]
11+
},
12+
{
13+
"cell_type": "markdown",
14+
"metadata": {},
15+
"source": [
16+
"###Problem 1\n",
17+
"\n",
18+
"Use map to create a function which finds the length of each word in the phrase\n",
19+
"(broken by spaces) and return the values in a list.\n",
20+
"\n",
21+
"The function will have an input of a string, and output a list of integers."
22+
]
23+
},
24+
{
25+
"cell_type": "code",
26+
"execution_count": 1,
27+
"metadata": {
28+
"collapsed": true
29+
},
30+
"outputs": [],
31+
"source": [
32+
"def word_lengths(phrase):\n",
33+
" \n",
34+
" pass"
35+
]
36+
},
37+
{
38+
"cell_type": "code",
39+
"execution_count": 4,
40+
"metadata": {
41+
"collapsed": false
42+
},
43+
"outputs": [
44+
{
45+
"data": {
46+
"text/plain": [
47+
"[3, 4, 3, 3, 5, 2, 4, 6]"
48+
]
49+
},
50+
"execution_count": 4,
51+
"metadata": {},
52+
"output_type": "execute_result"
53+
}
54+
],
55+
"source": [
56+
"word_lengths('How long are the words in this phrase')"
57+
]
58+
},
59+
{
60+
"cell_type": "markdown",
61+
"metadata": {},
62+
"source": [
63+
"###Problem 2 \n",
64+
"\n",
65+
"Use reduce to take a list of digits and return the number that they\n",
66+
"correspond to. *Do not convert the integers to strings!* "
67+
]
68+
},
69+
{
70+
"cell_type": "code",
71+
"execution_count": 2,
72+
"metadata": {
73+
"collapsed": true
74+
},
75+
"outputs": [],
76+
"source": [
77+
"def digits_to_num(digits):\n",
78+
" \n",
79+
" pass"
80+
]
81+
},
82+
{
83+
"cell_type": "code",
84+
"execution_count": 8,
85+
"metadata": {
86+
"collapsed": false
87+
},
88+
"outputs": [
89+
{
90+
"data": {
91+
"text/plain": [
92+
"34321"
93+
]
94+
},
95+
"execution_count": 8,
96+
"metadata": {},
97+
"output_type": "execute_result"
98+
}
99+
],
100+
"source": [
101+
"digits_to_num([3,4,3,2,1])"
102+
]
103+
},
104+
{
105+
"cell_type": "markdown",
106+
"metadata": {},
107+
"source": [
108+
"###Problem 3\n",
109+
"\n",
110+
"Use filter to return the words from a list of words which start with a target letter."
111+
]
112+
},
113+
{
114+
"cell_type": "code",
115+
"execution_count": 3,
116+
"metadata": {
117+
"collapsed": true
118+
},
119+
"outputs": [],
120+
"source": [
121+
"def filter_words(word_list, letter):\n",
122+
" \n",
123+
" pass"
124+
]
125+
},
126+
{
127+
"cell_type": "code",
128+
"execution_count": 10,
129+
"metadata": {
130+
"collapsed": false
131+
},
132+
"outputs": [
133+
{
134+
"data": {
135+
"text/plain": [
136+
"['hello', 'ham', 'hi', 'heart']"
137+
]
138+
},
139+
"execution_count": 10,
140+
"metadata": {},
141+
"output_type": "execute_result"
142+
}
143+
],
144+
"source": [
145+
"l = ['hello','are','cat','dog','ham','hi','go','to','heart']\n",
146+
"filter_words(l,'h')"
147+
]
148+
},
149+
{
150+
"cell_type": "markdown",
151+
"metadata": {},
152+
"source": [
153+
"###Problem 4\n",
154+
"\n",
155+
"Use zip and list comprehension to return a list of the same length where each value is the two strings from\n",
156+
"L1 and L2 concatenated together with connector between them. Look at the example output below:"
157+
]
158+
},
159+
{
160+
"cell_type": "code",
161+
"execution_count": 4,
162+
"metadata": {
163+
"collapsed": true
164+
},
165+
"outputs": [],
166+
"source": [
167+
"def concatenate(L1, L2, connector):\n",
168+
" \n",
169+
" pass"
170+
]
171+
},
172+
{
173+
"cell_type": "code",
174+
"execution_count": 14,
175+
"metadata": {
176+
"collapsed": false
177+
},
178+
"outputs": [
179+
{
180+
"data": {
181+
"text/plain": [
182+
"['A-a', 'B-b']"
183+
]
184+
},
185+
"execution_count": 14,
186+
"metadata": {},
187+
"output_type": "execute_result"
188+
}
189+
],
190+
"source": [
191+
"concatenate(['A','B'],['a','b'],'-')"
192+
]
193+
},
194+
{
195+
"cell_type": "markdown",
196+
"metadata": {},
197+
"source": [
198+
"###Problem 5\n",
199+
"\n",
200+
"Use enumerate and other skills to return a dictionary which has the values of the list as keys and the index as the value. You may assume that a value will only appear once in the given list.\n"
201+
]
202+
},
203+
{
204+
"cell_type": "code",
205+
"execution_count": 5,
206+
"metadata": {
207+
"collapsed": true
208+
},
209+
"outputs": [],
210+
"source": [
211+
"def d_list(L):\n",
212+
" \n",
213+
" pass"
214+
]
215+
},
216+
{
217+
"cell_type": "code",
218+
"execution_count": 20,
219+
"metadata": {
220+
"collapsed": false
221+
},
222+
"outputs": [
223+
{
224+
"data": {
225+
"text/plain": [
226+
"{'a': 0, 'b': 1, 'c': 2}"
227+
]
228+
},
229+
"execution_count": 20,
230+
"metadata": {},
231+
"output_type": "execute_result"
232+
}
233+
],
234+
"source": [
235+
"d_list(['a','b','c'])"
236+
]
237+
},
238+
{
239+
"cell_type": "markdown",
240+
"metadata": {},
241+
"source": [
242+
"###Problem 6\n",
243+
"\n",
244+
"Use enumerate and other skills from above to return the count of the number of items in the list whose value equals its index.\n"
245+
]
246+
},
247+
{
248+
"cell_type": "code",
249+
"execution_count": 6,
250+
"metadata": {
251+
"collapsed": true
252+
},
253+
"outputs": [],
254+
"source": [
255+
"def count_match_index(L):\n",
256+
" \n",
257+
" pass"
258+
]
259+
},
260+
{
261+
"cell_type": "code",
262+
"execution_count": 24,
263+
"metadata": {
264+
"collapsed": false
265+
},
266+
"outputs": [
267+
{
268+
"data": {
269+
"text/plain": [
270+
"4"
271+
]
272+
},
273+
"execution_count": 24,
274+
"metadata": {},
275+
"output_type": "execute_result"
276+
}
277+
],
278+
"source": [
279+
"count_match_index([0,2,2,1,5,5,6,10])"
280+
]
281+
},
282+
{
283+
"cell_type": "markdown",
284+
"metadata": {},
285+
"source": [
286+
"# Great Job!"
287+
]
288+
}
289+
],
290+
"metadata": {
291+
"kernelspec": {
292+
"display_name": "Python 2",
293+
"language": "python",
294+
"name": "python2"
295+
},
296+
"language_info": {
297+
"codemirror_mode": {
298+
"name": "ipython",
299+
"version": 2
300+
},
301+
"file_extension": ".py",
302+
"mimetype": "text/x-python",
303+
"name": "python",
304+
"nbconvert_exporter": "python",
305+
"pygments_lexer": "ipython2",
306+
"version": "2.7.10"
307+
}
308+
},
309+
"nbformat": 4,
310+
"nbformat_minor": 0
311+
}

0 commit comments

Comments
 (0)