-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.html
More file actions
528 lines (489 loc) · 29.8 KB
/
index.html
File metadata and controls
528 lines (489 loc) · 29.8 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
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
<!DOCTYPE html>
<html class="sl-root base export loaded">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Python for Developers: Slides</title>
<meta name="description" content="Slides">
<link rel="stylesheet" type="text/css" href="lib/offline-v2.css">
</head>
<body class="reveal-viewport theme-font-sketch theme-color-black-mint">
<div class="reveal">
<div class="slides">
<section class="stack"><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 250px; height: auto;" data-block-id="288c17a99ed49b1f130199be273d14ec"><div class="sl-block-content" data-placeholder-tag="h1" data-placeholder-text="Title Text">
<h1>Python for Developers</h1>
</div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 190px; height: auto;" data-block-id="9727efad6677fc5add99d70fe1ca6ad8"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text" style="z-index: 11;">
<h2>Python Classes in RU</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 470px; left: 80px; top: 490px; height: auto;" data-block-id="3f1cc8dfb9cbaeccee56b2f32320412b"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 12;">
<ul>
<li>Objective:
<ul>
<li>20% lecture</li>
<li>80% labs and interaction</li>
</ul>
</li>
</ul>
</div></div>
<div class="sl-block" data-block-type="image" data-block-id="5ec48c0953187140c6c8a0bc052d8c8f" style="min-width: 30px; min-height: 30px; width: 774.358px; height: 214px; left: 93px; top: 264px;"><div class="sl-block-content" style="z-index: 13;"><img data-natural-width="626" data-natural-height="173" style="" data-src="python-for-developers/2215860-python_at_rackspace.jpg"></div></div>
<div class="sl-block" data-block-type="line" data-block-id="35442ccf25cdbf53af7a6dc65bbca41c" style="width: auto; height: auto; min-width: 1px; min-height: 1px; left: 667px; top: 440px;"><div class="sl-block-content" data-line-x1="289" data-line-y1="310" data-line-x2="260" data-line-y2="209" data-line-color="#0000ff" data-line-start-type="none" data-line-end-type="arrow" style="z-index: 14;" data-line-width="4px"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" preserveaspectratio="xMidYMid" width="29" height="101" viewbox="260 209 29 101"><line stroke="rgba(0,0,0,0)" stroke-width="15" x1="289" y1="310" x2="262" y2="215"></line><line stroke="#0000ff" stroke-width="4" x1="289" y1="310" x2="262" y2="215"></line><polygon fill="#0000ff" transform="translate(262,215) rotate(-16.02)" points="0,-6 6,6 -6,6"></polygon></svg></div></div>
<div class="sl-block" data-block-type="text" data-block-id="91254fecec0fe124acfa10e1b78fc89b" style="height: auto; min-width: 30px; min-height: 30px; width: 220px; left: 598px; top: 541px;"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 15; color: rgb(0, 0, 255);">
<p>You Are Here</p>
</div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 190px; height: auto;" data-block-id="9a7ab3025ce642af41d3a2a7606c3f96"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text">
<h2>Introductions</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 264px; height: auto;" data-block-id="f4e192003c0fba937e36066d243f7895"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text">
<ul>
<li>Length of time at Rackspace</li>
<li>Job/Role</li>
<li>What is your programming experience?</li>
<li>How long have you been programming?</li>
<li>Why are you learning Python?</li>
<li>Favorite programming language?</li>
<li>Most hated programming language?<br>
</li>
</ul>
</div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 0px; height: auto;" data-block-id="61a142470e1246c7b7b0c7e409a76e8f"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text">
<h2>Resources</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 70px; height: auto;" data-block-id="a31db0ffa21e8f8f4510a524eeb10fc7"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text">
<ul>
<li><a href="https://github.com/jeremyprice/PythonForDevs" target="_blank">https://github.com/jeremyprice/PythonForDevs</a></li>
<li>Two books in PDF format:
<ul>
<li>Think Python</li>
<li>Python for Informatics</li>
</ul>
</li>
<li>
<strong>DemoProgs</strong>
<ul>
<li>a collection of Python programs that concentrate on specific aspects of the language</li>
</ul>
</li>
<li>
<strong>Samples</strong>
<ul>
<li>a set of screen shots designed to augment classroom discussion.</li>
</ul>
</li>
<li>
<strong>LabsData</strong>
<ul>
<li>data and code to be used in lab exercises.</li>
</ul>
</li>
</ul>
</div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 0px; height: auto;" data-block-id="9c4542ecce3f25e2232ea33091d0578c"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text">
<h2>Resources</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 70px; height: auto;" data-block-id="f2ea535cfb7cdd48b2b5ab07737c36c7"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text">
<ul>
<li><a href="https://github.com/jeremyprice/PythonForDevs" target="_blank">https://github.com/jeremyprice/PythonForDevs</a></li>
<li>
<strong>Python Notes</strong>
<ul>
<li>a set of notes with explanations of various topics and pointers to articles containing more explanations.</li>
<li>It is also a collection of methods used by various Python data structures.</li>
</ul>
</li>
<li>
<strong>Python Notes Addendum</strong>
<ul>
<li>a short document containing pointers to intermediate-level Python topics.</li>
</ul>
</li>
<li>
<strong>LabsDone</strong>
<ul>
<li>a collection of completed labs to be sent at the conclusion of the class.</li>
</ul>
</li>
</ul>
</div></div></section></section><section class="stack"><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 270px; height: auto;" data-block-id="a616badaa40047645dba63b8457f03a9"><div class="sl-block-content" data-placeholder-tag="h1" data-placeholder-text="Title Text">
<h1>Logistics</h1>
</div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 0px; height: auto;" data-block-id="86c1fe7eaa0a0d615e8128dfbd02170a"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text">
<h2>The Zen of Python</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 118px; top: 74px; height: auto;" data-block-id="7bf232e9c35d9735b6ab6f4fed2a7bed"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="font-size: 70%;">
<p style="text-align:left"><span style="font-size:1.0em">The Zen of Python, by Tim Peters</span></p>
<p style="text-align:left"><span style="font-size:1.0em">Beautiful is better than ugly.<br>
Explicit is better than implicit.<br>
Simple is better than complex.<br>
Complex is better than complicated.<br>
Flat is better than nested.<br>
Sparse is better than dense.<br>
Readability counts.<br>
Special cases aren't special enough to break the rules.<br>
Although practicality beats purity.<br>
Errors should never pass silently.<br>
Unless explicitly silenced.<br>
In the face of ambiguity, refuse the temptation to guess.<br>
There should be one-- and preferably only one --obvious way to do it.<br>
Although that way may not be obvious at first unless you're Dutch.<br>
Now is better than never.<br>
Although never is often better than *right* now.<br>
If the implementation is hard to explain, it's a bad idea.<br>
If the implementation is easy to explain, it may be a good idea.<br>
Namespaces are one honking great idea -- let's do more of those!</span></p>
</div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 190px; height: auto;" data-block-id="f74471e876685460ed7a3da36fdc7414"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text">
<h2>Our Lab Environment</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 264px; height: auto;" data-block-id="b56f078afa9df728d2c43b18ca04df90"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text">
<ul>
<li>Command line / Vim / Any other editor</li>
<li>I suggest Atom unless you have a favorite already <a href="https://atom.io" target="_blank">https://atom.io</a>
</li>
<li>IDLE
<ul>
<li>Very modest IDE</li>
<li>Really primarily a calculator/editor</li>
<li>Interactive vs Editing windows</li>
</ul>
</li>
<li>Demo<br>
</li>
</ul>
</div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 0px; height: auto;" data-block-id="310dcaa2b04a70a91449924543d05e7d"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text">
<h2>Python Help</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 74px; height: auto;" data-block-id="f10473e6d9b574f39356156c5caf319a"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text">
<ul>
<li>Google!</li>
<li>Interactive shell - help()</li>
<li>At bash prompt: pydoc
<ul>
<li>
<pre>pydoc -k string
pydoc module
pydoc -p 9999</pre>
</li>
</ul>
</li>
<li>Windows Powershell
<ul>
<li>
<pre>python –m pydoc module</pre>
</li>
</ul>
</li>
<li>Pydoc documentation
<ul>
<li>
<pre>pydoc pydoc</pre>
</li>
</ul>
</li>
</ul>
</div></div></section></section><section class="stack"><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 270px; height: auto;" data-block-id="d7b6a3c7074e7c50b2d007eccd3ec6f2"><div class="sl-block-content" data-placeholder-tag="h1" data-placeholder-text="Title Text">
<h1>Python Basics</h1>
</div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 16px; height: auto;" data-block-id="8f70f8991339bf838b830e41ae832903"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text" style="z-index: 10;">
<h2>Print Statement</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 116px; height: auto;" data-block-id="d39e3f3452d9f1263f30c7637bd5bd1d"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11;">
<ul>
<li>The print statement is used to output one or more expressions separated by commas.</li>
<li>General form:</li>
<li>
<ul>
<li>where expression can be a variable, literal or any valid expression</li>
</ul>
</li>
<li>By default, each item is separated by a space.</li>
<li>Automatically skips to next line when done, unless ended with a comma (,)</li>
</ul>
</div></div>
<div class="sl-block" data-block-type="code" data-block-id="c369493d7243117d70ab5a9ad6be1eaf" style="min-width: 30px; min-height: 30px; width: 500px; height: 35px; left: 150px; top: 245px;"><div class="sl-block-content" style="z-index: 13;"><pre class="python"><code>print expression1[, expression2,…,expressionN][,]</code></pre></div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 18px; height: auto;" data-block-id="2f7328a618158da9a3ae4ef66234f3f9"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text" style="z-index: 11;">
<h2>Print Statement Examples</h2>
</div></div>
<div class="sl-block" data-block-type="code" data-block-id="44ca2a3beb00721491520f9e6853e281" style="min-width: 30px; min-height: 30px; width: 490px; height: 152px; left: 230px; top: 113px;"><div class="sl-block-content" style="z-index: 12;"><pre class="python"><code># Examples:
a = 12.3
print 'The value of', a, 'is in variable a.'
print 'Is that enough?'
print 'The value of', a, 'is in variable a.',
print 'Is that enough?'
</code></pre></div></div>
<div class="sl-block" data-block-type="code" data-block-id="edfd76bb7372f5ed031fd341162986bf" style="min-width: 30px; min-height: 30px; width: 550px; height: 107px; left: 200px; top: 302px;"><div class="sl-block-content" style="z-index: 13;"><pre class="diff"><code># Output:
The value of 12.3 is in variable a.
Is that enough?
The value of 12.3 is in variable a. Is that enough?</code></pre></div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 15px; height: auto;" data-block-id="4a03e676023de8536cefd277b6a833a9"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text">
<h2>Basic Data Types</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 140px; height: auto;" data-block-id="a669bb896e677f32e9ee22d286413c87"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text">
<pre style="text-align: center;">integer
float
string
boolean
None</pre>
</div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 15px; height: auto;" data-block-id="b7928a7253203e19af88e62a22f0ac50"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text">
<h2>Identifiers and Types</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 93px; height: auto;" data-block-id="9361e26a6113eea56b534f061a6dcdad"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text">
<ul>
<li>Python uses weak data typing
<ul>
<li>Duck Typing FTW!</li>
</ul>
</li>
<li>Data type is established with an assignment statement.
<ul>
<li>
<pre>x = 10 (integer)</pre>
</li>
<li>
<pre>y = 12.34 (float)</pre>
</li>
<li>
<pre>z = ‘text data’ (string)</pre>
</li>
</ul>
</li>
<li>You do not specify a size or precision for numbers.</li>
<li>Integers are essentially unlimited in size</li>
<li>Floats are all double precision</li>
<li>Python is very generous in allocating memory to variables.</li>
<li>Demo program – sizecalc.py<br>
</li>
</ul>
</div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 14px; height: auto;" data-block-id="8b85cd88581ac9d939587d49c841db48"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text" style="z-index: 11;">
<h2>Math Operators</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 484px; height: auto;" data-block-id="c04cbf6614ee622ec22ad11281d139d7"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 12;">
<ul>
<li>
<p>Compound operators (e.g., +=, -=, etc) work the same in Python as other languages. </p>
<ul>
<li>
<p>No ++ postfix/prefix!</p>
</li>
</ul>
</li>
</ul>
</div></div>
<div class="sl-block" data-block-type="table" data-block-id="ac5c0a7e2dbe38d82de0cfb6ddda9a11" style="height: auto; min-width: 120px; min-height: 30px; width: 800px; left: 80px; top: 94px;"><div class="sl-block-content" style="z-index: 13; text-align: center;" data-table-cols="2" data-table-has-header="false" data-table-rows="7"><table><tbody>
<tr>
<td>**</td>
<td>Exponentiation</td>
</tr>
<tr>
<td>/</td>
<td>Division</td>
</tr>
<tr>
<td>*</td>
<td>Multiplication</td>
</tr>
<tr>
<td>+</td>
<td>Addition</td>
</tr>
<tr>
<td>-</td>
<td>Subtraction</td>
</tr>
<tr>
<td>%</td>
<td>Modulus (Remainder)</td>
</tr>
<tr>
<td>//</td>
<td>Floor Division</td>
</tr>
</tbody></table></div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 190px; height: auto;" data-block-id="16cf32a23bb1e2d03b978c428543db17"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text">
<h2>Operator Precedence</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 264px; height: auto;" data-block-id="defbc94d72a37ab7586c2dbe7f6159e5"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text">
<ul>
<li>Precedence is the same as all other languages</li>
</ul>
<ol>
<li>Exponentiation</li>
<li>Multiplication/Division (left to right)</li>
<li>Addition/Subtraction (left to right)</li>
<li>Only parentheses change the order of execution.<br>
</li>
</ol>
</div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 22px; height: auto;" data-block-id="857c9bd440a0591fabb9ddd68379c1c8"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text">
<h2>Integer Math</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 145px; height: auto;" data-block-id="ac8aff195a48f17b876723f8b0c02398"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text">
<ul>
<li>
<p>Math with integers produces an integer result in Python 2.</p>
<ul>
<li>
<p>7/3 = 2</p>
</li>
<li>
<p>7//3 = 2</p>
</li>
</ul>
</li>
<li>
<p>In Python 3, this changes. </p>
<ul>
<li>
<p>Any division in Python 3 yields a float. </p>
</li>
<li>
<p>7/3 = 2.3333</p>
</li>
<li>
<p>Only floor division gives 7//3 = 2</p>
</li>
</ul>
</li>
</ul>
</div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 19px; height: auto;" data-block-id="4b9965eb366bd06a5b2b8aed819f90ef"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text" style="z-index: 10;">
<h2>Variable Assignment</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 93px; height: auto;" data-block-id="caa40824a7f37f196ed1192dc4cbfe9a"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11;">
<ul>
<li>General assignments:</li>
</ul>
</div></div>
<div class="sl-block" data-block-type="code" data-block-id="583ad4b3d42598d338cc268737220b31" style="min-width: 30px; min-height: 30px; width: 714px; height: 167px; left: 123px; top: 151px;"><div class="sl-block-content" style="z-index: 13;"><pre class="python"><code>x = 12.3
x = x + 1
y = x + 117
z = 12 * x / y
a = “This is a line of text”
b = “ and so is this”
c = a + b # (string concatenation – do not mix strings with numbers)
d = 20 * ‘-’ # (string replication)</code></pre></div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 19px; height: auto;" data-block-id="166e16255a1aeaaccfca3fe3ea0e6062"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text" style="z-index: 10;">
<h2>Variable Assignment</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 93px; height: auto;" data-block-id="a91a3c43bf81367c36bb64d7fefc7e49"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11;">
<ul>
<li>In Python, there can be more than one variable on the left side.</li>
</ul>
<p> </p>
<p> </p>
<ul>
<li>This swaps the values of the two variables</li>
<li>Later, this technique will be used to unpack multi-valued variables into individual variables.</li>
<li>See a0Assignments.jpg in Samples</li>
</ul>
</div></div>
<div class="sl-block" data-block-type="code" data-block-id="e998deb1e1883244b587590f5568ec0f" style="min-width: 30px; min-height: 30px; width: 128px; height: 37px; left: 288px; top: 218px;"><div class="sl-block-content" style="z-index: 13;"><pre class="python"><code>x, y = y, x </code></pre></div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 22px; height: auto;" data-block-id="be03cf4565b7d7a17f711ad5c1efd682"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text" style="z-index: 10;">
<h2>Comments and String Literals</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 113px; height: auto;" data-block-id="3d35588a1254d01b37140d2e6904ef0c"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11;">
<ul>
<li>Comments work the same as most languages. A # is used as the delimiter.</li>
<li>String literals can be enclosed in single quotes (') or double quotes (") if they are contained on one line. </li>
<li>triple single-quotes (''') or triple double-quotes (""") are usually employed with literals or documentation that spans multiple lines.<br>
</li>
</ul>
</div></div>
<div class="sl-block" data-block-type="image" data-block-id="859ca193522dca6ef8d6a78d3d6631c4" style="min-width: 30px; min-height: 30px; width: 691.047px; height: 283px; left: 135px; top: 386px;"><div class="sl-block-content" style="z-index: 13;"><img data-natural-width="525" data-natural-height="215" style="" data-src="python-for-developers/2217811-pasted-from-clipboard.png"></div></div></section><section class="has-dark-background" data-background-color="#a8276b"><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 10px; height: auto;" data-block-id="86b8cee29996d4accb1a50c9205f4ae2"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text">
<h2>Lab 01 - Formulas</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 140px; height: auto;" data-block-id="7de20644b1ba7a6e30978b736c50f8a6"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text">
<ul>
<li>Create a program to solve these problems and print the results. Place each value specified by the problem into a variable before doing any calculations. Do not worry about the formatting of the answers. Your program should be such that you can change any of the numbers below and get a new answer.
<ul>
<li>You bought 125 shares of a stock at $25.32 and you sold it at $48.97. What is the profit?</li>
<li>A product with a price of $127.99 is going on sale. If the price is reduced by 16%, what will the new price be?</li>
</ul>
</li>
</ul>
</div></div></section></section><section class="stack"><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 270px; height: auto;" data-block-id="9da8c7abde06babb07fa3b097511b13b"><div class="sl-block-content" data-placeholder-tag="h1" data-placeholder-text="Title Text">
<h1>Formatting Data</h1>
</div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 23px; height: auto;" data-block-id="5bd42677c222c3ce8734bb71a08bf37a"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text" style="z-index: 11;">
<h2>Formatting Data into Strings</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 121px; height: auto;" data-block-id="a15524c6e1f39ab6fa9382a451236c92"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 12;">
<ul>
<li>General examples:<br>
</li>
</ul>
</div></div>
<div class="sl-block" data-block-type="code" data-block-id="956e26ae24e0892985871ad643d79703" style="min-width: 30px; min-height: 30px; width: 640px; height: 220px; left: 160px; top: 200px;"><div class="sl-block-content" style="z-index: 13;"><pre class="python"><code>x = 'Some text {} more text {}'.format(12, 17.426)
# Result: 'Some text 12 more text 17.426'
x = 'Some text {1} more text {0}'.format(12, 17.426)
# Result: 'Some text 17.426 more text 12 '
x = 'Some text {0:5d} more text {1:7.2f}'.format(12, 17.426)
# Result: 'Some text 12 more text 17.43'
# (Note rounding)</code></pre></div></div>
<div class="sl-block" data-block-type="text" data-block-id="7523b463086dbbf6fe50ac3fbd2e1818" style="height: auto; min-width: 30px; min-height: 30px; width: 600px; left: 180px; top: 461px;"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 14;">
<p>See examples in Sample folder - a2Formats.jpg and a3Formats.jpg</p>
</div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 79px; top: 50px; height: auto;" data-block-id="eddeb457c81bc84c357b8fe8801fcadc"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text" style="z-index: 10;">
<h2>a2Formats</h2>
</div></div>
<div class="sl-block" data-block-type="image" data-block-id="9df2e65fecb6d044cea1f7eb3a3976e9" style="min-width: 30px; min-height: 30px; width: 835.945px; height: 470px; left: 61px; top: 140px;"><div class="sl-block-content" style="z-index: 13;"><img style="" data-natural-width="715" data-natural-height="402" data-src="python-for-developers/2217835-pasted-from-clipboard.png"></div></div></section><section><div class="sl-block" data-block-type="text" style="width: 800px; left: 79px; top: 50px; height: auto;" data-block-id="f5821826d0002d802949a3f80e0344c9"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text" style="z-index: 10;">
<h2>a3Formats</h2>
</div></div>
<div class="sl-block" data-block-type="image" data-block-id="053ae1e759a6fc65e2a0253abf0184cc" style="min-width: 30px; min-height: 30px; width: 801px; height: 470.631px; left: 80px; top: 140px;"><div class="sl-block-content" style="z-index: 12;"><img data-natural-width="691" data-natural-height="406" style="" data-src="python-for-developers/2217840-pasted-from-clipboard.png"></div></div></section><section class="has-dark-background" data-background-color="#a8276b"><div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 10px; height: auto;" data-block-id="f86a0d04a6a212d3a2cd75681ecdcc0f"><div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text">
<h2>Lab 02</h2>
</div></div>
<div class="sl-block" data-block-type="text" style="width: 800px; left: 80px; top: 84px; height: auto;" data-block-id="a01e2fd64872da512eb129cc2005b807"><div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text">
<ul>
<li>Go back and format the results from the last lab.</li>
</ul>
<p> </p>
<ul>
<li>For more examples, see Python Notes and a2Formats.jpg and a3Formats.jpg in the Samples folder.</li>
</ul>
<p> </p>
<ul>
<li>This is the newer method. The older formatting style in Python is a bit different, but quite similar. </li>
</ul>
<p> </p>
<ul>
<li>Example: “There are %d %s in the box” % (5, “cookies”)</li>
</ul>
<p> </p>
<ul>
<li>Further examples are in a1Formats.jpg in the Samples folder.<br>
</li>
</ul>
</div></div></section></section>
</div>
</div>
<script>
var SLConfig = {"deck": {"id":604725,"slug":"python-for-developers","title":"Python for Developers","description":"Introduction to Python for Developers already using other languages","visibility":"self","published_at":null,"sanitize_messages":null,"thumbnail_url":"https://s3.amazonaws.com/media-p.slid.es/thumbnails/secure/cef8d8/decks.jpg","view_count":0,"user":{"id":105368,"username":"racku","name":"Rackspace University","description":"","thumbnail_url":"https://www.gravatar.com/avatar/4fdd35b37f5a9854774386e628b420fe?s=140\u0026d=https%3A%2F%2Fs3.amazonaws.com%2Fstatic.slid.es%2Fimages%2Fdefault-profile-picture.png","pro":true,"enterprise":false,"enterprise_manager":false,"settings":{"id":245,"present_controls":true,"present_upsizing":true,"present_notes":true},"registered":true},"background_transition":"slide","transition":"default","theme_id":null,"theme_font":"sketch","theme_color":"black-mint","auto_slide_interval":0,"comments_enabled":true,"forking_enabled":false,"rolling_links":false,"center":false,"should_loop":false,"share_notes":false,"slide_number":true,"rtl":false,"version":2,"notes":{}}};
SLConfig.current_user = {
name: "Rackspace University",
username: "racku",
pro: true
};
</script>
<script src="lib/head.min.js"></script>
<script src="lib/reveal.min.js"></script>
<script>
// Make Slides speaker notes available in the reveal.js speaker view
if( SLConfig.deck.notes ) {
[].forEach.call( document.querySelectorAll( '.reveal .slides section' ), function( slide ) {
var value = SLConfig.deck.notes[ slide.getAttribute( 'data-id' ) ];
if( value && typeof value === 'string' ) {
slide.setAttribute( 'data-notes', value );
}
} );
}
Reveal.initialize({
controls: true,
progress: true,
history: true,
mouseWheel: false,
showNotes: SLConfig.deck.share_notes,
slideNumber: SLConfig.deck.slide_number,
autoSlide: SLConfig.deck.auto_slide_interval || 0,
autoSlideStoppable: true,
rolling_links: SLConfig.deck.rolling_links || true,
center: SLConfig.deck.center || false,
loop: SLConfig.deck.should_loop || false,
rtl: SLConfig.deck.rtl || false,
transition: SLConfig.deck.transition,
backgroundTransition: SLConfig.deck.background_transition,
maxScale: 2,
dependencies: [
{ src: 'lib/reveal-plugins/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'lib/reveal-plugins/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'lib/reveal-plugins/highlight/highlight.js', async: true, callback: function() { hljs.initHighlighting(); hljs.initHighlightingOnLoad(); } },
{ src: 'lib/reveal-plugins/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>