|
44 | 44 | }, |
45 | 45 | { |
46 | 46 | "cell_type": "code", |
47 | | - "execution_count": null, |
48 | | - "metadata": { |
49 | | - "collapsed": false |
50 | | - }, |
51 | | - "outputs": [], |
| 47 | + "execution_count": 1, |
| 48 | + "metadata": {}, |
| 49 | + "outputs": [ |
| 50 | + { |
| 51 | + "name": "stdout", |
| 52 | + "output_type": "stream", |
| 53 | + "text": [ |
| 54 | + "True means do something\n" |
| 55 | + ] |
| 56 | + } |
| 57 | + ], |
52 | 58 | "source": [ |
53 | 59 | "if True:\n", |
54 | 60 | " print(\"True means do something\")\n", |
|
58 | 64 | }, |
59 | 65 | { |
60 | 66 | "cell_type": "code", |
61 | | - "execution_count": null, |
62 | | - "metadata": { |
63 | | - "collapsed": false |
64 | | - }, |
65 | | - "outputs": [], |
| 67 | + "execution_count": 2, |
| 68 | + "metadata": {}, |
| 69 | + "outputs": [ |
| 70 | + { |
| 71 | + "name": "stdout", |
| 72 | + "output_type": "stream", |
| 73 | + "text": [ |
| 74 | + "enjoy some hot tea!\n" |
| 75 | + ] |
| 76 | + } |
| 77 | + ], |
66 | 78 | "source": [ |
67 | 79 | "hot_tea = True\n", |
68 | 80 | "\n", |
|
74 | 86 | }, |
75 | 87 | { |
76 | 88 | "cell_type": "code", |
77 | | - "execution_count": null, |
78 | | - "metadata": { |
79 | | - "collapsed": false |
80 | | - }, |
| 89 | + "execution_count": 3, |
| 90 | + "metadata": {}, |
81 | 91 | "outputs": [], |
82 | 92 | "source": [ |
83 | 93 | "someone_i_know = False\n", |
|
90 | 100 | }, |
91 | 101 | { |
92 | 102 | "cell_type": "code", |
93 | | - "execution_count": null, |
94 | | - "metadata": { |
95 | | - "collapsed": false |
96 | | - }, |
97 | | - "outputs": [], |
| 103 | + "execution_count": 4, |
| 104 | + "metadata": {}, |
| 105 | + "outputs": [ |
| 106 | + { |
| 107 | + "name": "stdout", |
| 108 | + "output_type": "stream", |
| 109 | + "text": [ |
| 110 | + "how have you been?\n" |
| 111 | + ] |
| 112 | + } |
| 113 | + ], |
98 | 114 | "source": [ |
99 | 115 | "# changed the value of someone_i_know\n", |
100 | 116 | "someone_i_know = True\n", |
|
121 | 137 | }, |
122 | 138 | { |
123 | 139 | "cell_type": "code", |
124 | | - "execution_count": null, |
125 | | - "metadata": { |
126 | | - "collapsed": false |
127 | | - }, |
128 | | - "outputs": [], |
| 140 | + "execution_count": 5, |
| 141 | + "metadata": {}, |
| 142 | + "outputs": [ |
| 143 | + { |
| 144 | + "name": "stdout", |
| 145 | + "output_type": "stream", |
| 146 | + "text": [ |
| 147 | + "Go out there and seize the day!!!!!\n" |
| 148 | + ] |
| 149 | + } |
| 150 | + ], |
129 | 151 | "source": [ |
130 | 152 | "sunny_today = True\n", |
131 | 153 | "# [ ] test if it is sunny_today and give proper responses using if and else\n", |
| 154 | + "if sunny_today:\n", |
| 155 | + " print(\"Go out there and seize the day!!!!!\")\n", |
| 156 | + "else:\n", |
| 157 | + " print(\"Boardgames may be your best alternative.\")\n", |
| 158 | + "\n", |
132 | 159 | "\n" |
133 | 160 | ] |
134 | 161 | }, |
135 | 162 | { |
136 | 163 | "cell_type": "code", |
137 | | - "execution_count": null, |
138 | | - "metadata": { |
139 | | - "collapsed": false |
140 | | - }, |
141 | | - "outputs": [], |
| 164 | + "execution_count": 6, |
| 165 | + "metadata": {}, |
| 166 | + "outputs": [ |
| 167 | + { |
| 168 | + "name": "stdout", |
| 169 | + "output_type": "stream", |
| 170 | + "text": [ |
| 171 | + "Boardgames may be your best alternative.\n" |
| 172 | + ] |
| 173 | + } |
| 174 | + ], |
142 | 175 | "source": [ |
143 | 176 | "sunny_today = False\n", |
144 | 177 | "# [ ] use code you created above and test sunny_today = False\n", |
145 | | - "\n" |
| 178 | + "if sunny_today:\n", |
| 179 | + " print(\"Go out there and seize the day!!!!!\")\n", |
| 180 | + "else:\n", |
| 181 | + " print(\"Boardgames may be your best alternative.\")\n" |
146 | 182 | ] |
147 | 183 | }, |
148 | 184 | { |
|
173 | 209 | }, |
174 | 210 | { |
175 | 211 | "cell_type": "code", |
176 | | - "execution_count": null, |
177 | | - "metadata": { |
178 | | - "collapsed": false |
179 | | - }, |
180 | | - "outputs": [], |
| 212 | + "execution_count": 7, |
| 213 | + "metadata": {}, |
| 214 | + "outputs": [ |
| 215 | + { |
| 216 | + "name": "stdout", |
| 217 | + "output_type": "stream", |
| 218 | + "text": [ |
| 219 | + "Enter the title of a favorite book: Anna katerina\n", |
| 220 | + "Anna katerina - consider capitalization throughout for book titles.\n" |
| 221 | + ] |
| 222 | + } |
| 223 | + ], |
181 | 224 | "source": [ |
182 | 225 | "# review code and run cell\n", |
183 | 226 | "favorite_book = input(\"Enter the title of a favorite book: \")\n", |
|
190 | 233 | }, |
191 | 234 | { |
192 | 235 | "cell_type": "code", |
193 | | - "execution_count": null, |
194 | | - "metadata": { |
195 | | - "collapsed": false |
196 | | - }, |
197 | | - "outputs": [], |
| 236 | + "execution_count": 10, |
| 237 | + "metadata": {}, |
| 238 | + "outputs": [ |
| 239 | + { |
| 240 | + "name": "stdout", |
| 241 | + "output_type": "stream", |
| 242 | + "text": [ |
| 243 | + "enter a positive integer number: one\n", |
| 244 | + "one is not a positive integer\n", |
| 245 | + "one is more like a word\n" |
| 246 | + ] |
| 247 | + } |
| 248 | + ], |
198 | 249 | "source": [ |
199 | 250 | "# review code and run cell\n", |
200 | 251 | "a_number = input(\"enter a positive integer number: \")\n", |
|
213 | 264 | }, |
214 | 265 | { |
215 | 266 | "cell_type": "code", |
216 | | - "execution_count": null, |
217 | | - "metadata": { |
218 | | - "collapsed": false |
219 | | - }, |
220 | | - "outputs": [], |
| 267 | + "execution_count": 12, |
| 268 | + "metadata": {}, |
| 269 | + "outputs": [ |
| 270 | + { |
| 271 | + "name": "stdout", |
| 272 | + "output_type": "stream", |
| 273 | + "text": [ |
| 274 | + "\"enter a type of vehicle that starts with \"P\": toyota\n", |
| 275 | + "toyota does not start with \"P\"\n" |
| 276 | + ] |
| 277 | + } |
| 278 | + ], |
221 | 279 | "source": [ |
222 | 280 | "# review code and run cell\n", |
223 | 281 | "vehicle_type = input('\"enter a type of vehicle that starts with \"P\": ')\n", |
|
244 | 302 | }, |
245 | 303 | { |
246 | 304 | "cell_type": "code", |
247 | | - "execution_count": null, |
248 | | - "metadata": { |
249 | | - "collapsed": false |
250 | | - }, |
251 | | - "outputs": [], |
| 305 | + "execution_count": 18, |
| 306 | + "metadata": {}, |
| 307 | + "outputs": [ |
| 308 | + { |
| 309 | + "name": "stdout", |
| 310 | + "output_type": "stream", |
| 311 | + "text": [ |
| 312 | + "Test string 1 is lowercase throughout\n", |
| 313 | + "Test string 2 is not lowercase throughout\n" |
| 314 | + ] |
| 315 | + } |
| 316 | + ], |
252 | 317 | "source": [ |
253 | 318 | "test_string_1 = \"welcome\"\n", |
254 | 319 | "test_string_2 = \"I have $3\"\n", |
255 | 320 | "# [ ] use if, else to test for islower() for the 2 strings\n", |
256 | | - "\n" |
| 321 | + "if test_string_1.islower():\n", |
| 322 | + " print(\"Test string 1 is lowercase throughout\")\n", |
| 323 | + "else:\n", |
| 324 | + " print(\"Test string 1 is not lowercase throughout\")\n", |
| 325 | + "if test_string_2.islower():\n", |
| 326 | + " print(\"Test string 2 is lowercase throughout\")\n", |
| 327 | + "else:\n", |
| 328 | + " print(\"Test string 2 is not lowercase throughout\")" |
257 | 329 | ] |
258 | 330 | }, |
259 | 331 | { |
|
268 | 340 | }, |
269 | 341 | { |
270 | 342 | "cell_type": "code", |
271 | | - "execution_count": null, |
272 | | - "metadata": { |
273 | | - "collapsed": false |
274 | | - }, |
275 | | - "outputs": [], |
| 343 | + "execution_count": 24, |
| 344 | + "metadata": {}, |
| 345 | + "outputs": [ |
| 346 | + { |
| 347 | + "name": "stdout", |
| 348 | + "output_type": "stream", |
| 349 | + "text": [ |
| 350 | + "String does start with a 'w'\n", |
| 351 | + "String does not start with a 'w'\n", |
| 352 | + "String does not start with a 'w'\n" |
| 353 | + ] |
| 354 | + } |
| 355 | + ], |
276 | 356 | "source": [ |
277 | 357 | "test_string_1 = \"welcome\"\n", |
278 | 358 | "test_string_2 = \"I have $3\"\n", |
279 | 359 | "test_string_3 = \"With a function it's efficient to repeat code\"\n", |
280 | 360 | "# [ ] create a function w_start_test() use if & else to test with startswith('w')\n", |
281 | | - "\n", |
| 361 | + "def w_start_test(test_string):\n", |
| 362 | + " if test_string.startswith('w'):\n", |
| 363 | + " print(\"String does start with a 'w'\")\n", |
| 364 | + " else:\n", |
| 365 | + " print(\"String does not start with a 'w'\")\n", |
282 | 366 | "# [ ] Test the 3 string variables provided by calling w_start_test()\n", |
283 | | - "\n" |
| 367 | + "w_start_test(test_string_1 )\n", |
| 368 | + "w_start_test(test_string_2 )\n", |
| 369 | + "w_start_test(test_string_3 )" |
284 | 370 | ] |
285 | 371 | }, |
286 | 372 | { |
|
308 | 394 | "name": "python", |
309 | 395 | "nbconvert_exporter": "python", |
310 | 396 | "pygments_lexer": "ipython3", |
311 | | - "version": "3.5.2" |
| 397 | + "version": "3.8.8" |
312 | 398 | } |
313 | 399 | }, |
314 | 400 | "nbformat": 4, |
|
0 commit comments