forked from gdiannarbor/intro-programming-concepts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
726 lines (644 loc) · 31.5 KB
/
index.html
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Intro to Programming Concepts ~ Girl Develop It Los Angeles</title>
<meta name="description" content="This is an updated version of the programming concepts curriculum, based on Boulder and Philly">
<meta name="author" content="Girl Develop It Los Angeles">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/simple.css" id="theme">
<!-- For syntax highlighting -->
<!-- light editor --><link rel="stylesheet" href="lib/css/light.css">
<!-- dark editor <link rel="stylesheet" href="lib/css/dark.css">-->
<!-- <link rel="stylesheet" href="lib/css/zenburn.css"> -->
<link rel="stylesheet" href="plugin/accessibility-helper/css/accessibility-helper.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<!-- If use the PDF print sheet so students can print slides-->
<link rel="stylesheet" href="css/print/pdf.css" type="text/css" media="print">
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<!-- Title -->
<section>
<img src="img/circle-gdi-logo.png" alt="GDI Logo" class="noborder"/>
<h2>Introduction to <br>Programming Concepts</h2>
<h3>...for true beginners!</h3>
<p><small>Slides: <a href="http://gdila.org/programming">http://gdila.org/programming</a></small></p>
</section>
<!-- Welcome -->
<section>
<h1>Welcome!</h1>
<p>Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.</p>
<p class="green">Some “rules”</p>
<ul>
<li>We are here for you!</li>
<li>Every question is important</li>
<li>Help each other</li>
<li>Have fun</li>
</ul>
</section>
<!-- Introductions -->
<section class="hide-pdf">
<h1>Tell us about yourself</h1>
<ul>
<li>Who are you?</li>
<li>What do you hope to get out of the class?</li>
<li>What are you binging on right now? e.g. music, tv shows, podcasts, food, drinks -- whatever you like</li>
</ul>
</section>
<!-- Teacher -->
<section class="hide-pdf">
<h1>About Me</h1>
</section>
<!-- What we'll cover -->
<section>
<h1>What we’ll cover today</h1>
<ul>
<li class="fragment">What is a computer program?</li>
<li class="fragment">Variables</li>
<li class="fragment">Memory and storage</li>
<li class="fragment">Logical operators</li>
<li class="fragment">Conditional statements</li>
<li class="fragment">Loops</li>
<li class="fragment">Comments</li>
</ul>
</section>
<!-- Computer Programs -->
<section>
<h1>Computer Programs</h1>
<ul>
<li class="fragment">Computer programs are <span class="green">everywhere.</span>
<ul class="fragment">
<li>They run parts of your car</li>
<li>They let you check your email on your phone</li>
<li>They comb through millions of results to match your search terms on the web</li>
</ul>
</li>
</ul>
<p> </p>
<p class="fragment">But how do you go from an idea to a computer program? And what <em class="green">is</em> a computer program?</p>
</section>
<!-- What is code -->
<section>
<h1>What is code?</h1>
<p>Turns out, you’re not the only person to wonder this.</p>
<p>Paul Ford wrote a 38,000-word essay called <a href="https://www.bloomberg.com/graphics/2015-paul-ford-what-is-code/" target="_new">“What is code”</a> that was published on June 11, 2015 in Bloomsburg Business Week, and it captured the attention of many.</p>
</section>
<!-- What is a computer program -->
<section>
<h1>What is a Computer Program?</h1>
<div class="left-align">
<p>At its core, a computer program is <strong class="green">a way of getting something done</strong>.</p>
<p class="fragment">One of the ways to accomplish “getting something done” is a list of instructions that tells the computer exactly what to do and allows interaction with human beings.</p>
<p class="fragment">Those instructions have to be written in a “language” that the computer can understand.</p>
</div>
</section>
<!-- Computer programs -->
<section>
<h1>Computer Programs</h1>
<div class="left-align">
<p>Computers don’t understand things the same way humans do. Words and symbols that make sense to human eyes need to be translated down to binary for the computer to understand.</p>
<p class="fragment"><strong class="blue">Binary</strong> is a system of expressing everything using only 1s and 0s.</p>
<p class="fragment">For example, in ASCII (one system of encoding in binary), the lower case letter ‘a’ is represented as ‘1100001’.</p>
</div>
</section>
<!-- Computer language chart -->
<section>
<h2>Computer Languages</h2>
<p>From human-readable languages to binary:</p>
<img src="img/computerlanguages.png" alt="Computer Language Chart">
<p><small>Image credit: <a href="Image credit: https://blog.malwarebytes.org/intelligence/2012/09/so-you-want-to-be-a-malware-analyst/
">blog.malwarebytes.org/intelligence/2012/09/so-you-want-to-be-a-malware-analyst/
</a></small></p>
</section>
<!-- Computer programs analogy -->
<section>
<h1>Computer Programs</h1>
<p>One can draw an analogy from a computer to the human body, and from coders to scientists!</p>
<ul>
<li class="fragment">Programmers who work with high-level languages treat computers the way a primary care physician looks at your body. They take a holistic approach to understanding how your organs work together.</li>
<li class="fragment">Programmers who work with low-level languages treat computers the way a researcher might investigate a disease in your body. They may need to understand specifics of how parts of your cells work in order to understand how they’re malfunctioning.</li>
</ul>
</section>
<!-- Programming Languages -->
<section>
<h1>Programming Languages</h1>
<p>So which human-readable programming language do you choose to use?</p>
<p class="fragment">It depends on the task you’re trying to accomplish!</p>
<p class="fragment">Different languages are designed to do different things.</p>
</section>
<!-- Uses for different programming languages -->
<section>
<h1>Programming Languages</h1>
<p>For example:</p>
<ul>
<li class="fragment">To develop websites, you might use <strong class="blue">HTML, JavaScript, Python, Java, PHP</strong>.</li>
<li class="fragment">To create databases and move information in and out of them, you might use <strong class="blue">MySQL, SQL, Dbase</strong>.</li>
<li class="fragment">To write applications like Microsoft Word or Adobe Acrobat, you might use <strong class="blue">C++, Java, Visual Basic</strong></li>
</ul>
</section>
<!-- Computers are dumb -->
<section>
<h1>Computers are dumb</h1>
<ul>
<li class="fragment">Computers can only do what they have instructions for — and they take those instructions VERY literally.</li>
<li class="fragment">As a result, you have to tell them every single thing you want them to do and every single thing to take into consideration.</li>
<li class="fragment">If you leave any instructions out (or put them in the “wrong” order), the results might not be what you expect.</li>
</ul>
</section>
<!-- Literal computer language demo -->
<section>
<h1>Demonstration</h1>
<p>I need a volunteer…</p>
</section>
<!-- PEBKAC -->
<section>
<h1>PEBKAC</h1>
<p class="fragment"><strong class="green">P</strong>roblem <strong class="green">E</strong>xists <strong class="green">B</strong>etween <strong class="green">K</strong>eyboard <strong class="green">A</strong>nd <strong class="green">C</strong>hair</p>
<p class="fragment">In other words, <strong class="blue">user error</strong>.</p>
<p class="fragment">Remember, when you’re writing a program and the computer is executing it, the computer is only doing what you told it to do. If it’s not working the way you expect, look for an error in your program.</p>
</section>
<!-- Intro to Hello World -->
<section>
<h1>Hello, World!</h1>
<p>Just like English has the concepts of vocabulary and grammar, so do computer languages.</p>
<p class="fragment">In computer programming, the <strong class="blue">syntax</strong> of a computer language is what defines if the combination of letters and symbols used are considered a valid construction in that language.</p>
</section>
<!-- Hello World Explanation -->
<section>
<h1>Hello, World!</h1>
<p>When you’re first playing around and learning the syntax of a new computer language, one of the most common first exercises is called <code class="green">"Hello, World!"</code>.</p>
<p>The <code class="green">"Hello, World!"</code> program is one that outputs the text <code class="green">"Hello, World!"</code> on the screen for the user.</p>
<p>This task is usually relatively simple to accomplish in most programming languages, so it’s a good warm-up exercise.</p>
</section>
<!-- Intro to coding exercise -->
<section>
<h1>Hello, World!</h1>
<p>There are <a href="http://helloworldcollection.de/" target="_new">many, many, many examples</a> in many, many, many languages.</p>
</section>
<!-- Coding exercise -->
<section>
<h1>Let’s Develop It!</h1>
<p>We’re going to use a website called <a href="https://repl.it/" target="_new">repl.it</a> to try out <code class="green">"Hello, World!"</code> in a language or two.</p>
<p>Choose a language and paste in the hello world code from the <a href="http://helloworldcollection.de/" target="_new">Hello World collection</a>.</p>
<p>Click the <strong class="green">Run</strong> button to see the program run.</p>
</section>
<!-- Starting a project -->
<section>
<h1>Getting Started</h1>
<p>Once you have a project and a language, you’ll want to program your project in that language.</p>
<p>Let’s talk about some of the basic foundational building blocks of all programming languages.</p>
<p>Keep in mind that each language may have a different <strong class="blue">syntax</strong> for expressing these concepts, but the underlying concepts will be the same through them all.</p>
</section>
<!-- Programming Structures -->
<section>
<h1>Programming structures</h1>
<ul>
<li>No matter what programming language you use, the structures that are available are usually fairly similar.
<ul>
<li><span class="blue">Variables</span></li>
<li>Logical structures:
<ul>
<li><span class="blue">Conditional statements</span></li>
<li><span class="blue">Loops</span></li>
</ul>
</li>
</ul>
</li>
</ul>
</section>
<!-- Variables -->
<section>
<h1>Variables</h1>
<ul>
<li class="fragment">A variable is a storage container for information.</li>
<li class="fragment">A variable has a name that you use to refer to it, and a value, which is the information it contains.</li>
<li class="fragment">For example:
<ul>
<li><code>age = 28</code></li>
<li><code>color = blue</code></li>
</ul>
</li>
<li class="fragment">There are different types of variables based on the information that you want to store.</li>
</ul>
</section>
<!-- Integers/Floats -->
<section>
<h1>Integers and Floats</h1>
<ul>
<li><span class="blue">Integer</span> variables are used to store integers (0 as well as positive and negative whole numbers).</li>
<li class="fragment"><span class="blue">Float</span> variables are used to store numbers with fractional values (that is, containing decimal places).</li>
<li class="fragment">For example, consider shopping on Amazon:
<ul>
<li class="fragment">The number of books you can order is stored as an integer (e.g., 2)</li>
<li class="fragment">The price of the books is stored as a float (e.g., 15.99)</li>
</ul>
</li>
<li class="fragment">Not every programming language makes a distinction between these two, but it’s good to be aware of.</li>
</ul>
</section>
<!-- Strings -->
<section>
<h1>Strings</h1>
<ul>
<li><span class="blue">String</span> variables are used to store text. A string is made up of characters like letters, numbers, and symbols.</li>
<li class="fragment">For example, on Amazon.com:
<ul>
<li class="fragment">In your profile, information like your name, address, state, and city are stored as strings.</li>
<li class="fragment">An item’s description is stored as a string</li>
</ul>
</li>
<li class="fragment">Usually when you’re creating a string variable, you will need to surround the value with either single or double quotation marks (either <code>'</code> or <code>"</code>) to specify the start and end of the string. (Remember how <code>"Hello, World!"</code> had quotes?)</li>
</ul>
</section>
<!-- Numbers as strings -->
<section>
<h1>Numbers as Strings</h1>
<ul>
<li>You can store a number as a string variable, but then you typically can’t use it in any mathematical calculations.</li>
<li class="fragment">For example, phone numbers are integers, but you would never use them in a mathematical calculation, so you could store them either way.</li>
<li class="fragment">As another example, consider postal codes. If you store them as integers, then you can only support postal codes from the USA! Other countries use postal codes with letters in them (e.g., BL1 1AD is in the UK).</li>
</ul>
</section>
<!-- Booleans -->
<section>
<h1>Boolean Variables</h1>
<ul>
<li><span class="blue">Boolean</span> variables are used to store the value <code>TRUE</code> or <code>FALSE</code> (yes or no).</li>
<li class="fragment">Booleans are most frequently used to control whether certain functionality is enabled or disabled.</li>
<li class="fragment">For example, back on Amazon.com, if your login credentials validate, this may be stored as a <code>"true"</code> (yes). As a result, your account information displays, your cart is populated, etc.</li>
</ul>
</section>
<!-- End of variables section -->
<section>
<h1>Questions?</h1>
<p>Any unanswered questions about variables or types of variables?</p>
</section>
<!-- Storage and Memory -->
<section>
<h1>Storage and Memory</h1>
<p>You may be asking yourself how exactly the computer “stores” these variables. As anyone who’s shopped for a computer knows, there are a lot of terms when it comes to computer storage and memory. Let’s briefly touch on them.</p>
</section>
<!-- RAM -->
<section>
<h1>Memory</h1>
<p><strong class="blue">RAM</strong> or <strong class="blue">Random Access Memory</strong> is where the computer does its “thinking”.</p>
<p>This is where programs temporarily store data like variables while executing programs. Data in RAM is frequently overwritten and is destroyed when you turn off your computer.</p>
</section>
<!-- ROM -->
<section>
<h1>Memory</h1>
<p><strong class="blue">ROM</strong> or <strong class="blue">Read-Only Memory</strong> is for the most part not editable.</p>
<p>It’s used by the computer to store important pieces of data when switched on, like data about the operating system.</p>
</section>
<!-- Storage -->
<section>
<h1>Storage</h1>
<p><strong class="blue">Storage</strong> a more permanent type of memory. The computer user can utilize it to keep data around even after the computer is turned off.</p>
<p>Examples include the hard drive on the computer, a thumb drive, or an external hard drive.</p>
</section>
<!-- End of Memory and Storage -->
<section>
<h1>Questions?</h1>
<p>Any unanswered questions about memory and storage?</p>
</section>
<!-- Operators -->
<section>
<h1>Operators</h1>
<p>Now that we have variables storing data for us, what can we do with them?</p>
<p>We use operators to compare, combine, or evaluate combinations of variables in order to produce some desired output. We could then store this output in another variable, if we wanted!</p>
</section>
<!-- Operator Examples -->
<section>
<h1>Operators</h1>
<p>Some examples of operators:</p>
<table style="margin-left:auto;margin-right:auto;margin-bottom:1em;">
<thead>
<tr>
<th>Operator</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>=</code></td>
<td>equal to</td>
</tr>
<tr>
<td><code>!=</code></td>
<td>not equal to</td>
</tr>
<tr>
<td><code>></code></td>
<td>greater than</td>
</tr>
<tr>
<td><code><</code></td>
<td>less than</td>
</tr>
<tr>
<td><code>>=</code></td>
<td>greater than or equal to</td>
</tr>
<tr>
<td><code><=</code></td>
<td>less than or equal to</td>
</tr>
<tr>
<td><code>&&</code><span class="blue">*</span></td>
<td>and</td>
</tr>
<tr>
<td><code>||</code><span class="blue">*</span></td>
<td>or</td>
</tr>
</tbody>
</table>
<p><small><span class="blue">*</span> These operators have different characters in different languages.</small></p>
</section>
<!-- End of Operators -->
<section>
<h1>Questions?</h1>
<p>Any unanswered questions about operators?</p>
</section>
<!-- Logical structures -->
<section>
<h1>Logical structures</h1>
<ul>
<li>Logical structures provide the framework for using that data to “get stuff done”.</li>
<li>If you understand the concepts, you can learn how to represent them in most programming languages.</li>
</ul>
</section>
<!-- Conditional Statements -->
<section>
<h1>Conditional Statements</h1>
<p class="green">If this, then that…</p>
<ul>
<li><strong class="blue">Conditional statements</strong> evaluate a condition and take actions based on the result.</li>
<li><strong class="green">If</strong> the given condition is <code>true</code>, Then the computer will do the actions you specify in the <code>if</code> clause. (In some languages, the word <code>then</code> is implied.)</li>
<li><strong class="green">Else</strong> (otherwise), if the given condition is <code>false</code>, the computer will do the actions you specify in the <code>else</code> clause.</li>
</ul>
</section>
<!-- Conditional Examples -->
<section>
<h1>Conditional Examples</h1>
<p>Another Amazon example…</p>
<ul>
<li class="fragment"><code>IF</code> you’re logged in, show your name and shopping cart contents. <code>ELSE</code>, show a link to the login page.</li>
<li class="fragment"><code>IF</code> you’re an Amazon Prime member, you get free shipping. <code>ELSE</code>, you have to pay for shipping!</li>
</ul>
</section>
<!-- Conditional Statment Practice -->
<section>
<h1>Let’s Develop It!</h1>
<h2>Part 1</h2>
<p>Let’s practice conditional statements in Ruby.</p>
<ul>
<li>Go back to <a href="http://repl.it/languages" target="_blank">repl.it</a> and choose <strong class="green">Ruby</strong> as the language.</li>
<li>Copy or type the following into the left-hand side and click the <strong class="green">Run</strong> button:</li>
</ul>
<pre><code class="ruby">cart_total = 8
if cart_total > 2
print "You get free shipping!"
end</code></pre>
<ul>
<li>Change the numbers and see what happens.</li>
<li>Change the operators (greater than, less than, etc.) and see what happens</li>
</ul>
</section>
<!-- Conditional Statement Practice -->
<section>
<h1>Let’s Develop It!</h1>
<h2>Part 2</h2>
<ul>
<li>Now let’s make this a little more complicated and add an <code>else</code> statement after the <code>if</code> statement.</li>
</ul>
<pre><code class="ruby">cart_total = 8
if cart_total > 2
print "You get free shipping!"
else
print "You'll have to pay for shipping."
end</code></pre>
<ul>
<li>Change the numbers and see what happens.</li>
<li>Change the operators (greater than, less than, etc.)</li>
<li>Change the string outputs.</li>
</ul>
</section>
<!-- End of Conditional Statements -->
<section>
<h1>Questions?</h1>
<p>Any unanswered questions about conditional statements?</p>
</section>
<!-- Loops -->
<section>
<h1>Loops</h1>
<p>A <strong class="blue">loop</strong> is a list of instructions that repeats until a certain condition is met.</p>
<ul>
<li>For example…
<ul>
<li class="fragment">In real life: As long as there are dirty dishes in the sink, keep washing dishes.</li>
<li class="fragment">On eBay: Allow bids on this auction until the auction timer hits 0.</li>
</ul>
</li>
</ul>
<p class="fragment">One reason to use a loop is to reduce the number of lines of code you need to write to accomplish a task.</p>
</section>
<!-- Why use loops? -->
<section>
<h1>Why Use Loops?</h1>
<ul>
<li>Loops are very powerful - they allow us to interact easily with each item in a collection of items.</li>
<li>Loops reduce the amount of code we have to write.
<ul>
<li>If you were stuck using only conditional statements, you might have to write hundres of lines of code to interact with a collection items.</li>
</ul>
</li>
</ul>
</section>
<!-- Infinite Loops -->
<section>
<h1>Infinite Loops</h1>
<p><strong class="green">Important:</strong> Beware the infinte loop!</p>
<ul>
<li class="fragment">An infinite loop is a loop that will never meet the condition to stop. For example, if you’re waiting for a variable (like that eBay timer) to reach 0, but the timer variable keeps <strong class="green">increasing</strong> instead of <strong class="green">decreasing</strong>, the loop will continue forever!</li>
<li class="fragment">Your program will keep running until it uses up all your computer’s RAM memory. This is <strong class="green">BAD!</strong></li>
</ul>
</section>
<!-- Loops types -->
<section>
<h1>Types of Loops</h1>
<p>There are two kinds of loops:</p>
<ol>
<li><code class="blue">while</code> loops</li>
<li><code class="blue">for</code> loops</li>
</ol>
</section>
<!-- While Loops -->
<section>
<h1>While Loops</h1>
<p>A <code>while</code> loop allows code to be executed repeatedly based on a given condition.</p>
<p class="fragment">Often based on the value of a variable.</p>
<p class="fragment">Usually your code will need to change the variable within the body of the loop.</p>
<p class="fragment"><strong class="green">Example:</strong> <code>While</code> it’s raining, bring an umbrella.</p>
</section>
<!-- While Loop Exercise -->
<section>
<h1>Let’s Develop It!</h1>
<ul>
<li>Head back to <a href="https://repl.it/" target="_new">repl.it</a> and selection <strong class="blue">Python</strong> as the language. (Not Python 3)</li>
<li>Copy or type the following into the left-hand side and click the <strong class="green">Run</strong> button:</li>
</ul>
<pre><code class="python">number_of_bottles = 99
while number_of_bottles > 0:
print number_of_bottles
print ' bottles of beer on the wall'
number_of_bottles = number_of_bottles - 1
print 'no more bottles of beer!'</code></pre>
<ul>
<li>Change the numbers to see what happens.</li>
<li>Change the operators (greater than, less than, etc.)</li>
<li>Change the string statements.</li>
</ul>
<p><small>Be careful not to create an infinite loop! <br>If you do, you may need to force-quit your browser!</small></p>
</section>
<!-- For Loops -->
<section>
<h1>For Loops</h1>
<p><code>For</code> loops are similar to while loops. They just have a different syntax.</p>
<p class="fragment">In a <code>for</code> loop, you set up the conditional <span class="green">and</span> increment or decrement your variable in the same line.</p>
</section>
<!-- For Loop Exercise -->
<section>
<h1>Let’s Develop It!</h1>
<ul>
<li>Let’s re-do the last exercise, but using a <code>for</code> loop this time.</li>
<li>Head back to <a href="https://repl.it/" target="_new">repl.it</a> and selection <strong class="blue">Python</strong> as the language. (Not Python 3)</li>
</ul>
<pre><code class="python">for number_of_bottles in range(99, 0, -1):
print number_of_bottles
print ' bottles of beer on the wall'
print 'no more bottles of beer!'</code></pre>
</section>
<!-- End of Loops Section -->
<section>
<h1>Questions?</h1>
<p>Any unanswered questions about loops?</p>
</section>
<!-- Comments -->
<section>
<h1>Comments</h1>
<p>One final thing to keep in mind is that it’s good practice to leave comments in your code. Comments are not executed by the program. They’re just there for you to read.</p>
<p class="fragment">Comments should explain why your code is doing what it’s doing.</p>
</section>
<!-- Comment Syntax -->
<section>
<h1>Comments</h1>
<p>The <strong class="blue">syntax</strong> for comments varies from language to language, but here are some common ways to create comments:</p>
<pre><code class="php"># The following code prints something
print 'hello, world!';
// And this code prints something too!
print 'hello, world!'
/* And this bit of code also prints something */
print 'hello, world!'</code></pre>
</section>
<!-- Why comments? -->
<section>
<h1>Why leave comments?</h1>
<ul>
<li class="fragment"><strong class="green">Teams!</strong> When you’re working a team, comments in the code help your teammates easily identify what bits of code are doing.</li>
<li class="fragment"><strong class="green">Explain oddities.</strong> Sometimes, you have to add a bit of code that seems odd to solve a problem. Leaving a comment explains why the code is there so it doesn’t accidentally get changed.</li>
<li class="fragment"><strong class="green">Yourself!</strong> You’ll thank your past self a million times over when you return to code you wrote 6 months or 2 years ago and need to update or change something if you’ve left nice comments explaining your code.</li>
</ul>
</section>
<!-- End of comments -->
<section>
<h1>Questions?</h1>
<p>Any unanswered questions about comments?</p>
</section>
<!-- What we learned today -->
<section>
<h1>What we learned today</h1>
<ul>
<li class="fragment">What is a computer program?</li>
<li class="fragment">Variables</li>
<li class="fragment">Memory and storage</li>
<li class="fragment">Logical operators</li>
<li class="fragment">Conditional statements</li>
<li class="fragment">Loops</li>
<li class="fragment">Comments</li>
</ul>
</section>
<!-- Resources -->
<section>
<h2>Coding Resources & Books</h2>
<ul>
<li>Code Year:<a href="http://www.codecademy.com/tracks/code-year" target="_blank">www.codecademy.com/tracks/code-year</a></li>
<li>Codecademy: <a href="http://www.codecademy.com" target="_blank">www.codecademy.com</a></li>
<li>Coursera: <a href="https://www.coursera.org" target="_blank">www.coursera.org</a></li>
<li>Kahn Academy: <a href="https://www.khanacademy.org" target="_blank">www.khanacademy.org</a></li>
<li>Skillcrush: <a href="http://skillcrush.com" target="_blank">www.skillcrush.com</a></li>
<li>Udacity: <a href="https://www.udacity.com" target="_blank">www.udacity.com</a></li>
<li>Udemy: <a href="https://www.udemy.com" target="_blank">www.udemy.com</a></li>
<li>And of course, <a href="http://gdila.org" target="_blank">GDI Los Angeles</a></li>
<li><a href="http://www.amazon.com/Program-Second-Edition-Facets-Series/dp/1934356360" target="_blank">Learn to Program</a>, by Chris Pine</li>
<li><a href="http://www.amazon.com/Everyday-Scripting-Ruby-Teams-Testers/dp/0977616614" target="_blank">Everyday Scripting in Ruby</a>, by Brian Marick</li>
</ul>
</section>
<!-- Thank you and survey -->
<section>
<h1>Thank you!</h1>
<p>Thank you for supporting Girl Develop It!</p>
<p>We strive to make every class better than the last. To help us, please complete this survey. It’s anonymous and your comments will only be seen by the organizers.</p>
<p><a href="https://goo.gl/DDH3SX">https://goo.gl/DDH3SX</a></p>
</section>
</div>
<footer>
<div class="copyright">
Introduction to Programming Concepts -- Los Angeles --
<a rel="license" href="http://creativecommons.org/licenses/by-nc/3.0/deed.en_US"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc/3.0/80x15.png" /></a>
</div>
</footer>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, condition: function() { return !!document.querySelector( 'pre code' ); }, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/accessibility-helper/js/accessibility-helper.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>