|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "code", |
5 | | - "execution_count": null, |
| 5 | + "execution_count": 10, |
6 | 6 | "metadata": { |
7 | 7 | "deletable": false, |
8 | 8 | "editable": false |
|
48 | 48 | }, |
49 | 49 | { |
50 | 50 | "cell_type": "code", |
51 | | - "execution_count": null, |
| 51 | + "execution_count": 11, |
52 | 52 | "metadata": {}, |
53 | 53 | "outputs": [], |
54 | 54 | "source": [ |
|
74 | 74 | }, |
75 | 75 | { |
76 | 76 | "cell_type": "code", |
77 | | - "execution_count": null, |
| 77 | + "execution_count": 15, |
78 | 78 | "metadata": { |
79 | 79 | "tags": [ |
80 | 80 | "otter_answer_cell" |
81 | 81 | ] |
82 | 82 | }, |
83 | | - "outputs": [], |
| 83 | + "outputs": [ |
| 84 | + { |
| 85 | + "name": "stderr", |
| 86 | + "output_type": "stream", |
| 87 | + "text": [ |
| 88 | + "<>:3: SyntaxWarning: invalid escape sequence '\\S'\n", |
| 89 | + "<>:3: SyntaxWarning: invalid escape sequence '\\S'\n", |
| 90 | + "C:\\Users\\HunterJi\\AppData\\Local\\Temp\\ipykernel_30872\\2403592241.py:3: SyntaxWarning: invalid escape sequence '\\S'\n", |
| 91 | + " clap_data = np.loadtxt(\"Data\\S01C01.csv\", dtype=\"float\", delimiter=\",\")\n" |
| 92 | + ] |
| 93 | + } |
| 94 | + ], |
84 | 95 | "source": [ |
85 | 96 | "\n", |
86 | 97 | "# TODO - put the code to load the data \n", |
87 | 98 | "# Make sure you save it into the variable name given - clap_data - or the autograder won't work.\n", |
88 | | - "clap_data = ..." |
| 99 | + "clap_data = np.loadtxt(\"Data\\S01C01.csv\", dtype=\"float\", delimiter=\",\")" |
89 | 100 | ] |
90 | 101 | }, |
91 | 102 | { |
92 | 103 | "cell_type": "code", |
93 | | - "execution_count": null, |
| 104 | + "execution_count": 16, |
94 | 105 | "metadata": { |
95 | 106 | "tags": [ |
96 | 107 | "otter_answer_cell" |
|
128 | 139 | }, |
129 | 140 | { |
130 | 141 | "cell_type": "code", |
131 | | - "execution_count": null, |
| 142 | + "execution_count": 21, |
132 | 143 | "metadata": { |
133 | 144 | "tags": [ |
134 | 145 | "otter_answer_cell" |
135 | 146 | ] |
136 | 147 | }, |
137 | | - "outputs": [], |
| 148 | + "outputs": [ |
| 149 | + { |
| 150 | + "name": "stdout", |
| 151 | + "output_type": "stream", |
| 152 | + "text": [ |
| 153 | + "Number of time steps: 101\n" |
| 154 | + ] |
| 155 | + } |
| 156 | + ], |
138 | 157 | "source": [ |
139 | 158 | "# TODO\n", |
140 | 159 | "# - set the n_time_steps variable. Do NOT just put in a number - use the variable clap_data to calculate this.\n", |
141 | 160 | "# - change the print line to print out the number of time steps\n", |
142 | | - "n_time_steps = ...\n", |
143 | | - "print(f\"Number of time steps: {}\")" |
| 161 | + "n_time_steps = np.shape(clap_data)[0]\n", |
| 162 | + "print(f\"Number of time steps: {n_time_steps}\")" |
144 | 163 | ] |
145 | 164 | }, |
146 | 165 | { |
147 | 166 | "cell_type": "code", |
148 | | - "execution_count": null, |
| 167 | + "execution_count": 22, |
149 | 168 | "metadata": { |
150 | 169 | "tags": [ |
151 | 170 | "otter_answer_cell" |
152 | 171 | ] |
153 | 172 | }, |
154 | | - "outputs": [], |
| 173 | + "outputs": [ |
| 174 | + { |
| 175 | + "name": "stdout", |
| 176 | + "output_type": "stream", |
| 177 | + "text": [ |
| 178 | + "Third column: [11.92438773 12.83811787 12.74563683 18.88675076 15.89095011]\n", |
| 179 | + "How many numbers are above 0.5? 5\n", |
| 180 | + "Sum of array as double 5.0 and integer 5\n" |
| 181 | + ] |
| 182 | + } |
| 183 | + ], |
155 | 184 | "source": [ |
156 | 185 | "# EXAMPLE CODE\n", |
157 | 186 | "# Remember you want all of the rows - that's what the : is for\n", |
|
173 | 202 | }, |
174 | 203 | { |
175 | 204 | "cell_type": "code", |
176 | | - "execution_count": null, |
| 205 | + "execution_count": 25, |
177 | 206 | "metadata": { |
178 | 207 | "tags": [ |
179 | 208 | "otter_answer_cell" |
180 | 209 | ] |
181 | 210 | }, |
182 | | - "outputs": [], |
| 211 | + "outputs": [ |
| 212 | + { |
| 213 | + "name": "stdout", |
| 214 | + "output_type": "stream", |
| 215 | + "text": [ |
| 216 | + "Number of datapoints with positive z: 53\n", |
| 217 | + "Number of datapoints with negative z: 48\n" |
| 218 | + ] |
| 219 | + } |
| 220 | + ], |
183 | 221 | "source": [ |
184 | 222 | "# TODO - set the variables n_pos_z and n_neg_z and print them out. Do NOT just put in a number - use the variable\n", |
185 | 223 | "# clap_data.\n", |
186 | 224 | "\n", |
187 | 225 | "\n", |
188 | | - "n_pos_z = ...\n", |
189 | | - "print(f\"Number of datapoints with positive z: {}\")\n", |
| 226 | + "n_pos_z = np.count_nonzero(clap_data[:,3] > 0) \n", |
| 227 | + "print(f\"Number of datapoints with positive z: {n_pos_z}\")\n", |
190 | 228 | "\n", |
191 | | - "n_neg_z = ...\n", |
192 | | - "print(f\"Number of datapoints with negative z: {}\")" |
| 229 | + "n_neg_z = np.count_nonzero(clap_data[:,3] < 0) \n", |
| 230 | + "print(f\"Number of datapoints with negative z: {n_neg_z}\")" |
193 | 231 | ] |
194 | 232 | }, |
195 | 233 | { |
|
936 | 974 | "name": "python", |
937 | 975 | "nbconvert_exporter": "python", |
938 | 976 | "pygments_lexer": "ipython3", |
939 | | - "version": "3.11.7" |
| 977 | + "version": "3.12.7" |
940 | 978 | }, |
941 | 979 | "otter": { |
942 | 980 | "OK_FORMAT": true, |
|
0 commit comments