|
10 | 10 | "name": "python2" |
11 | 11 | }, |
12 | 12 | "name": "", |
13 | | - "signature": "sha256:0f359e9c97dbdab0051d127b9eec4d41334bcbfbb69469d54cd2d85bfab89255" |
| 13 | + "signature": "sha256:5b78afa85dd8d13ddacbd2795e2e59031426989539554cff55ee4238d13cbf87" |
14 | 14 | }, |
15 | 15 | "nbformat": 3, |
16 | 16 | "nbformat_minor": 0, |
|
52 | 52 | "cell_type": "markdown", |
53 | 53 | "metadata": {}, |
54 | 54 | "source": [ |
55 | | - "A programming community outreach workshop, brought to you by the generous volunteers from:\n", |
| 55 | + "A programming community outreach workshop, brought to you by the generous volunteers and leadership from:\n", |
56 | 56 | "\n", |
57 | 57 | "- [PyLadies San Diego](www.meetup.com/sd-pyladies/)\n", |
58 | 58 | "- [San Diego Python User Group](www.meetup.com/pythonsd/)\n", |
59 | | - "- [Inland Empire Pyladies](www.meetup.com/iepyladies/)" |
| 59 | + "- [Inland Empire Pyladies](www.meetup.com/iepyladies/)\n", |
| 60 | + "\n", |
| 61 | + "Thanks to David and Kendall of SDPUG and Juliet of PyLadies SD for their support." |
60 | 62 | ] |
61 | 63 | }, |
62 | 64 | { |
|
68 | 70 | "- Danny\n", |
69 | 71 | "- Rise\n", |
70 | 72 | "- Trey\n", |
| 73 | + "- Alain\n", |
| 74 | + "- Micah\n", |
71 | 75 | "- Jim\n", |
72 | 76 | "- Others that are helping on day of event\n", |
73 | 77 | "- Carol\n", |
74 | 78 | "\n", |
75 | | - "Please take a moment to share 2-4 sentences about yourself\n", |
| 79 | + "Please take a moment to share 2-4 sentences about yourself.\n", |
76 | 80 | "\n", |
77 | 81 | "We are all volunteers. If you enjoy this workshop and decide to continue with Python programming, we encourage you to volunteer at the next Intro to Python Workshop.\n", |
78 | 82 | "\n", |
|
184 | 188 | "Let's get started with the interactive lecture" |
185 | 189 | ] |
186 | 190 | }, |
| 191 | + { |
| 192 | + "cell_type": "heading", |
| 193 | + "level": 3, |
| 194 | + "metadata": {}, |
| 195 | + "source": [ |
| 196 | + "Python as a Calculator" |
| 197 | + ] |
| 198 | + }, |
187 | 199 | { |
188 | 200 | "cell_type": "markdown", |
189 | 201 | "metadata": {}, |
190 | 202 | "source": [ |
191 | | - "Terminal and start python" |
| 203 | + "From your command prompt, type `python3` to enter IDLE.\n", |
| 204 | + "\n", |
| 205 | + "Some regular math operations." |
192 | 206 | ] |
193 | 207 | }, |
194 | 208 | { |
|
245 | 259 | "cell_type": "code", |
246 | 260 | "collapsed": false, |
247 | 261 | "input": [ |
248 | | - "1 / 2" |
| 262 | + "0.5/2" |
249 | 263 | ], |
250 | 264 | "language": "python", |
251 | 265 | "metadata": {}, |
|
255 | 269 | "cell_type": "markdown", |
256 | 270 | "metadata": {}, |
257 | 271 | "source": [ |
258 | | - "Whole number 1 divided by whole number 2" |
| 272 | + "**Special type of division (floor)**" |
259 | 273 | ] |
260 | 274 | }, |
261 | 275 | { |
262 | 276 | "cell_type": "code", |
263 | 277 | "collapsed": false, |
264 | 278 | "input": [ |
265 | | - "3 / 2" |
| 279 | + "3 // 2" |
266 | 280 | ], |
267 | 281 | "language": "python", |
268 | 282 | "metadata": {}, |
|
272 | 286 | "cell_type": "code", |
273 | 287 | "collapsed": false, |
274 | 288 | "input": [ |
275 | | - "15 / 2" |
| 289 | + "15.5 // 2" |
276 | 290 | ], |
277 | 291 | "language": "python", |
278 | 292 | "metadata": {}, |
279 | 293 | "outputs": [] |
280 | 294 | }, |
| 295 | + { |
| 296 | + "cell_type": "markdown", |
| 297 | + "metadata": {}, |
| 298 | + "source": [ |
| 299 | + "Horizontal line spacing does not matter in Python in an individual statement. In a multiline program it does, you typically indent 4 spaces." |
| 300 | + ] |
| 301 | + }, |
281 | 302 | { |
282 | 303 | "cell_type": "code", |
283 | 304 | "collapsed": false, |
284 | 305 | "input": [ |
285 | | - "1.0 / 2" |
| 306 | + "2 + 2" |
286 | 307 | ], |
287 | 308 | "language": "python", |
288 | 309 | "metadata": {}, |
|
292 | 313 | "cell_type": "code", |
293 | 314 | "collapsed": false, |
294 | 315 | "input": [ |
295 | | - "2 + 2" |
| 316 | + "2+2" |
296 | 317 | ], |
297 | 318 | "language": "python", |
298 | 319 | "metadata": {}, |
299 | 320 | "outputs": [] |
300 | 321 | }, |
| 322 | + { |
| 323 | + "cell_type": "markdown", |
| 324 | + "metadata": {}, |
| 325 | + "source": [ |
| 326 | + "Parens and order of operations follow typical mathematics conventions in Python. `_` in IPython signifies the previous result." |
| 327 | + ] |
| 328 | + }, |
301 | 329 | { |
302 | 330 | "cell_type": "code", |
303 | 331 | "collapsed": false, |
304 | 332 | "input": [ |
305 | | - "2+2" |
| 333 | + "(1 + 3) * 4" |
306 | 334 | ], |
307 | 335 | "language": "python", |
308 | 336 | "metadata": {}, |
|
312 | 340 | "cell_type": "code", |
313 | 341 | "collapsed": false, |
314 | 342 | "input": [ |
315 | | - "(1 + 3) * 4" |
| 343 | + "x = 4" |
316 | 344 | ], |
317 | 345 | "language": "python", |
318 | 346 | "metadata": {}, |
|
322 | 350 | "cell_type": "code", |
323 | 351 | "collapsed": false, |
324 | 352 | "input": [ |
325 | | - "x = 4" |
| 353 | + "x * 3" |
326 | 354 | ], |
327 | 355 | "language": "python", |
328 | 356 | "metadata": {}, |
|
332 | 360 | "cell_type": "code", |
333 | 361 | "collapsed": false, |
334 | 362 | "input": [ |
335 | | - "x * 3" |
| 363 | + "_ + 8" |
336 | 364 | ], |
337 | 365 | "language": "python", |
338 | 366 | "metadata": {}, |
|
342 | 370 | "cell_type": "markdown", |
343 | 371 | "metadata": {}, |
344 | 372 | "source": [ |
345 | | - "Variables" |
| 373 | + "**A trip to PyCon**" |
346 | 374 | ] |
347 | 375 | }, |
348 | 376 | { |
349 | 377 | "cell_type": "code", |
350 | 378 | "collapsed": false, |
351 | 379 | "input": [ |
352 | | - "cups_of_flour = 5" |
| 380 | + "jeans = 5" |
| 381 | + ], |
| 382 | + "language": "python", |
| 383 | + "metadata": {}, |
| 384 | + "outputs": [] |
| 385 | + }, |
| 386 | + { |
| 387 | + "cell_type": "code", |
| 388 | + "collapsed": false, |
| 389 | + "input": [ |
| 390 | + "shoes = 2" |
| 391 | + ], |
| 392 | + "language": "python", |
| 393 | + "metadata": {}, |
| 394 | + "outputs": [] |
| 395 | + }, |
| 396 | + { |
| 397 | + "cell_type": "code", |
| 398 | + "collapsed": false, |
| 399 | + "input": [ |
| 400 | + "socks = 12" |
353 | 401 | ], |
354 | 402 | "language": "python", |
355 | 403 | "metadata": {}, |
|
359 | 407 | "cell_type": "code", |
360 | 408 | "collapsed": false, |
361 | 409 | "input": [ |
362 | | - "cups_of_flour * .5" |
| 410 | + "shirts = 1" |
363 | 411 | ], |
364 | 412 | "language": "python", |
365 | 413 | "metadata": {}, |
|
369 | 417 | "cell_type": "code", |
370 | 418 | "collapsed": false, |
371 | 419 | "input": [ |
372 | | - "1 / 2\n" |
| 420 | + "items_packed = jeans + shoes + socks + shirts" |
373 | 421 | ], |
374 | 422 | "language": "python", |
375 | 423 | "metadata": {}, |
|
379 | 427 | "cell_type": "code", |
380 | 428 | "collapsed": false, |
381 | 429 | "input": [ |
382 | | - "1.0 / 2" |
| 430 | + "items_packed" |
| 431 | + ], |
| 432 | + "language": "python", |
| 433 | + "metadata": {}, |
| 434 | + "outputs": [] |
| 435 | + }, |
| 436 | + { |
| 437 | + "cell_type": "code", |
| 438 | + "collapsed": false, |
| 439 | + "input": [ |
| 440 | + "print(items_packed)" |
383 | 441 | ], |
384 | 442 | "language": "python", |
385 | 443 | "metadata": {}, |
|
389 | 447 | "cell_type": "markdown", |
390 | 448 | "metadata": {}, |
391 | 449 | "source": [ |
392 | | - "Two different data types\n", |
| 450 | + "**Using type() to find the datatype**\n", |
393 | 451 | "\n", |
394 | 452 | "\n", |
395 | | - "Let's use a function" |
| 453 | + "Let's use a function. You'll be hearing more about functions later today. For now let's say that a function is like a Personal Assistant. You ask for a job to be done, and if you give the assistant the correct instructions, he will do the tasks asked.\n", |
| 454 | + "\n", |
| 455 | + "One handy thing that our Python Personal Assistant, aka Funky Function, can do is tell us a variable's current data type." |
396 | 456 | ] |
397 | 457 | }, |
398 | 458 | { |
399 | 459 | "cell_type": "code", |
400 | 460 | "collapsed": false, |
401 | 461 | "input": [ |
402 | | - "type(1)" |
| 462 | + "type(shirts)" |
403 | 463 | ], |
404 | 464 | "language": "python", |
405 | 465 | "metadata": {}, |
|
409 | 469 | "cell_type": "code", |
410 | 470 | "collapsed": false, |
411 | 471 | "input": [ |
412 | | - "type(1.0)" |
| 472 | + "type(0.99)" |
413 | 473 | ], |
414 | 474 | "language": "python", |
415 | 475 | "metadata": {}, |
|
426 | 486 | "cell_type": "markdown", |
427 | 487 | "metadata": {}, |
428 | 488 | "source": [ |
429 | | - "String data type" |
| 489 | + "**String data type**" |
430 | 490 | ] |
431 | 491 | }, |
432 | 492 | { |
|
459 | 519 | "metadata": {}, |
460 | 520 | "outputs": [] |
461 | 521 | }, |
| 522 | + { |
| 523 | + "cell_type": "markdown", |
| 524 | + "metadata": {}, |
| 525 | + "source": [ |
| 526 | + "**Concatenating strings**" |
| 527 | + ] |
| 528 | + }, |
462 | 529 | { |
463 | 530 | "cell_type": "code", |
464 | 531 | "collapsed": false, |
|
493 | 560 | "cell_type": "code", |
494 | 561 | "collapsed": false, |
495 | 562 | "input": [ |
| 563 | + "\n", |
496 | 564 | "\"Carol \" + \"Willing\"\n" |
497 | 565 | ], |
498 | 566 | "language": "python", |
|
533 | 601 | "cell_type": "markdown", |
534 | 602 | "metadata": {}, |
535 | 603 | "source": [ |
536 | | - "Tip - arrow up save typing" |
| 604 | + "*Tip - arrow up to save time typing*" |
537 | 605 | ] |
538 | 606 | }, |
539 | 607 | { |
|
636 | 704 | "metadata": {}, |
637 | 705 | "outputs": [] |
638 | 706 | }, |
| 707 | + { |
| 708 | + "cell_type": "markdown", |
| 709 | + "metadata": {}, |
| 710 | + "source": [ |
| 711 | + "**Quotes (single, double, triple)**" |
| 712 | + ] |
| 713 | + }, |
639 | 714 | { |
640 | 715 | "cell_type": "code", |
641 | 716 | "collapsed": false, |
|
690 | 765 | "cell_type": "markdown", |
691 | 766 | "metadata": {}, |
692 | 767 | "source": [ |
693 | | - "Printing - interactive vs file" |
| 768 | + "**Displaying versus printing in IPython**" |
694 | 769 | ] |
695 | 770 | }, |
696 | 771 | { |
|
717 | 792 | "cell_type": "markdown", |
718 | 793 | "metadata": {}, |
719 | 794 | "source": [ |
720 | | - "Questions?" |
| 795 | + "Questions? Quick review" |
721 | 796 | ] |
722 | 797 | }, |
723 | 798 | { |
|
761 | 836 | "outputs": [] |
762 | 837 | }, |
763 | 838 | { |
764 | | - "cell_type": "markdown", |
| 839 | + "cell_type": "heading", |
| 840 | + "level": 3, |
765 | 841 | "metadata": {}, |
766 | 842 | "source": [ |
767 | 843 | "Make choices" |
|
1137 | 1213 | "metadata": {}, |
1138 | 1214 | "outputs": [] |
1139 | 1215 | }, |
| 1216 | + { |
| 1217 | + "cell_type": "markdown", |
| 1218 | + "metadata": {}, |
| 1219 | + "source": [ |
| 1220 | + "**Exiting the interpreter is a good thing to know.** \n", |
| 1221 | + "To exit, type `exit()` or press CNTL-D." |
| 1222 | + ] |
| 1223 | + }, |
1140 | 1224 | { |
1141 | 1225 | "cell_type": "markdown", |
1142 | 1226 | "metadata": {}, |
|
0 commit comments