-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractice_Module-2-Projects.ipynb.bak
More file actions
208 lines (208 loc) · 6.74 KB
/
Practice_Module-2-Projects.ipynb.bak
File metadata and controls
208 lines (208 loc) · 6.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
{
"cells": [
{
"cell_type": "markdown",
"id": "58493690-cee9-42a5-8165-5790cba1c05e",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
"# Practice: Module 2 Project (Lists, Iteration, Strings)\n",
"\n",
"## Reformat and count names\n",
"\n",
"Process the list to convert to lastname, firstname format. Count the number of names that have lastname \"Wright\". Be careful! There are some inconsistencies in upper/lowercase!\n",
"\n",
"e.g., the first three elements of the output list should look like\n",
"\n",
"`[\"Thompson, Amelia\", \"Martinez, Oscar\", \"Green, Sophie\"]`\n",
"\n",
"And you should print out a message that is formatted like this:\n",
"`\"There are M names with lastname Wright\"`\n",
"\n",
"Here is the correct output:\n",
"\n",
"`['Thompson, Amelia', 'Martinez, Oscar', 'Wright, Sophie', 'Harrison, Miles', 'Wright, Isabella', 'Patel, Lucas', 'Murphy, Chloe', 'Rodriguez, Leo', 'Lee, Ella', 'Kim, David', 'Chen, Emily', 'Davis, Oliver', 'Robinson, Lily', 'Adams, Caleb', 'wright, Ava', 'Garcia, Nathan', 'Hernandez, Grace', 'Brown, Ethan', 'Taylor, Avery', 'WrighT, Jacob']`\n",
"\n",
"`There are 4 names with lastname Wright`"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "82c95a45-86cc-4075-b2ec-b50d51229fbb",
"metadata": {},
"outputs": [],
"source": [
"# make sure you run this cell before you attempt your program\n",
"names = [\n",
" 'Amelia Thompson',\n",
" 'Oscar Martinez',\n",
" 'Sophie Wright',\n",
" 'Miles Harrison',\n",
" 'Isabella Wright',\n",
" 'Lucas Patel',\n",
" 'Chloe Murphy',\n",
" 'Leo Rodriguez',\n",
" 'Ella Lee',\n",
" 'David Kim',\n",
" 'Emily Chen',\n",
" 'Oliver Davis',\n",
" 'Lily Robinson',\n",
" 'Caleb Adams',\n",
" 'Ava wright',\n",
" 'Nathan Garcia',\n",
" 'Grace Hernandez',\n",
" 'Ethan Brown',\n",
" 'Avery Taylor',\n",
" 'Jacob WrighT'\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": 42,
"id": "abbcc6d6-f7c5-4bca-aec8-ab5bfec86663",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Thompson, Amelia', 'Martinez, Oscar', 'Wright, Sophie', 'Harrison, Miles', 'Wright, Isabella', 'Patel, Lucas', 'Murphy, Chloe', 'Rodriguez, Leo', 'Lee, Ella', 'Kim, David', 'Chen, Emily', 'Davis, Oliver', 'Robinson, Lily', 'Adams, Caleb', 'wright, Ava', 'Garcia, Nathan', 'Hernandez, Grace', 'Brown, Ethan', 'Taylor, Avery', 'WrighT, Jacob']\n",
"There are 4 names with lastname Wright\n"
]
}
],
"source": [
"# your code here"
]
},
{
"cell_type": "markdown",
"id": "5a904150-e2d6-42cc-90f5-e352abf428d1",
"metadata": {
"tags": []
},
"source": [
"## Clean dataset\n",
"\n",
"Clean this dataset. The values should all be between 0 and 100. Anything above 100 is an outlier. Anything coded -999 is a missing value. Compute the average value of the cleaned dataset (i.e., w/ outliers and missing removed), and report how many outliers and missing values there are. Your output message shoudl only show 3 decimal points.\n",
"\n",
"Here is the correct output:\n",
"\n",
"`[67, 96, 95, 78, 36, 94, 67, 85, 96, 60, 73, 45, 6, 17, 24, 82, 82, 100, 44, 81, 12, 60]`\n",
"\n",
"`After removing 4 missing values and 4 outliers, average value is 63.636`"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "1a6abbe9-2aba-4868-8bd3-81be44862ec7",
"metadata": {},
"outputs": [],
"source": [
"# make sure you run this cell before you attempt your program\n",
"data = ['67', '96', '95', '78', '36', '94', '67', '85', '96', '60', '73', '45', '6', '17', '24', '82', '125', '150', '136', '106', '82', '100', '44', '81', '12', '-999', '-999', '-999', '-999', '60']"
]
},
{
"cell_type": "code",
"execution_count": 44,
"id": "435f753b-3a2f-4554-9122-8885d60d37d8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[67, 96, 95, 78, 36, 94, 67, 85, 96, 60, 73, 45, 6, 17, 24, 82, 82, 100, 44, 81, 12, 60]\n",
"After removing 4 missing values and 4 outliers, average value is 63.636\n"
]
}
],
"source": [
"# your program here\n",
"\n"
]
},
{
"cell_type": "markdown",
"id": "01a94064-16ff-4452-bda7-748eff53ee94",
"metadata": {},
"source": [
"## Process submissions (with late penalties and exceptions)\n",
"\n",
"Here is a list of submissions that I want you to process.\n",
"\n",
"The submissions have three parts to them (separated by commas):\n",
"1. The score (0 to 100)\n",
"2. A value that indicates whether the submission was late (0 or 1)\n",
"3. A value that indicates whether the submission had a late exception\n",
"\n",
"Produce a final list of scores that applies a late penalty (reduce score by 20%) unless the submission has a late exception. \n",
"\n",
"Also, report:\n",
"1. The average score of the final list (M)\n",
"2. The number of non-exempted late submissions (N)\n",
"\n",
"In the following format:\n",
"`\"The average score (after penalizing N late submissions) is M\"`\n",
"\n",
"Make sure M is formatted with only 2 decimal points.\n",
"\n",
"Here is the correct output:\n",
"\n",
"`[62, 80, 5, 12.0, 64.0, 97, 61, 20, 56, 74, 73, 89, 57, 27.200000000000003, 63, 2, 27, 60, 33, 65.60000000000001]`\n",
"\n",
"`The average score (after penalizing 4 late submissions) is 51.39`"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "74f56354-ad42-41ac-a268-9a62f45b1631",
"metadata": {},
"outputs": [],
"source": [
"# make sure you run this cell before you attempt your program\n",
"submissions = ['62,0,0', '80,0,0', '5,0,0', '15,1,0', '80,1,0', '97,0,0', '61,0,0', '20,1,1', '56,0,0', '74,0,0', '73,0,0', '89,0,0', '57,0,0', '34,1,0', '63,0,0', '2,0,0', '27,0,0', '60,0,0', '33,1,1', '82,1,0']"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "04575542-012b-4db3-a7ba-5f6afff49191",
"metadata": {},
"outputs": [],
"source": [
"# your program here"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}