-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpertemuan05.html
More file actions
476 lines (445 loc) · 20 KB
/
pertemuan05.html
File metadata and controls
476 lines (445 loc) · 20 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
<!doctype html>
<html lang="en" data-theme="light">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="lms-url" content="https://lms.itera.ac.id">
<title>Pertemuan 5 - Perulangan</title>
<link rel="stylesheet" href="dist/reset.css">
<link rel="stylesheet" href="dist/reveal.css">
<link rel="stylesheet" href="dist/theme/simple.css">
<!-- Custom PKOM Theme (Shared Style) -->
<link rel="stylesheet" href="css/pkom-theme.css">
<!-- Syntax highlighting -->
<link rel="stylesheet" href="plugin/highlight/monokai.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
</head>
<body>
<button class="theme-toggle" type="button" aria-label="Toggle theme" title="Toggle theme"><i class="bi bi-moon"></i></button>
<div class="reveal">
<!-- Persistent Footer -->
<div class="footer-branding">
<div class="footer-logos">
<img src="logo/logo_itera.png" alt="Logo ITERA">
<img src="logo/logo_kampus_berdampak.png" alt="Logo Kampus Merdeka">
</div>
<div class="footer-copyright">
© 2026 Institut Teknologi Sumatera
</div>
</div>
<div class="slides">
<!-- === SLIDE 1: JUDUL === -->
<section>
<div class="title-box">
<h1>Pengenalan Komputasi</h1>
<h3 class="subtitle">Pertemuan 5: Perulangan (Loops)</h3>
</div>
</section>
<!-- === SLIDE 2: OUTLINE === -->
<section>
<h3>Outline Materi</h3>
<div class="flex-container" style="align-items: flex-start;">
<div class="flex-col card">
<h4 style="font-size: 0.9em; border-bottom: 2px solid #eee; padding-bottom: 10px;">Teori</h4>
<ul style="font-size: 0.7em;">
<li>Review Pertemuan 4</li>
<li>Konsep Perulangan</li>
<li><code>for</code> loop & <code>range()</code></li>
<li><code>while</code> loop</li>
</ul>
</div>
<div class="flex-col card">
<h4 style="font-size: 0.9em; border-bottom: 2px solid #eee; padding-bottom: 10px;">Praktek</h4>
<ul style="font-size: 0.7em;">
<li>Infinite Loop (Bahaya!)</li>
<li>break & continue</li>
<li>Studi Kasus</li>
<li><strong>Hands-on Practice</strong></li>
</ul>
</div>
</div>
</section>
<!-- === SLIDE 3: TUJUAN === -->
<section>
<h3>Tujuan Pembelajaran</h3>
<div class="text-left" style="font-size: 0.8em; margin-top: 30px;">
<p>Setelah mengikuti pertemuan ini, mahasiswa diharapkan mampu:</p>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px;">
<div class="card" style="padding: 15px;"><i class="bi bi-check-circle"></i> Menjelaskan konsep loop</div>
<div class="card" style="padding: 15px;"><i class="bi bi-check-circle"></i> Menulis for loop</div>
<div class="card" style="padding: 15px;"><i class="bi bi-check-circle"></i> Menulis while loop</div>
<div class="card" style="padding: 15px;"><i class="bi bi-check-circle"></i> Menggunakan break/continue</div>
</div>
</div>
</section>
<!-- === SLIDE 4: APA ITU LOOP === -->
<section>
<h3>Apa itu Perulangan?</h3>
<div class="flex-container">
<div class="flex-col text-left text-small">
<p><strong>Perulangan (Loop)</strong> adalah struktur kontrol yang memungkinkan blok kode
dieksekusi berulang kali.</p>
<div class="card card-danger" style="margin-top: 20px;">
<strong>TANPA Loop:</strong><br>
<code>print("Hello")</code><br>
<code>print("Hello")</code><br>
<code>print("Hello")</code><br>
<code>print("Hello")</code><br>
<code>print("Hello")</code>
</div>
</div>
<div class="flex-col">
<div class="card card-success">
<strong>DENGAN Loop:</strong>
<pre><code class="python">
for i in range(5):
print("Hello")
</code></pre>
<p class="text-smaller">Lebih singkat, efisien, dan mudah diubah!</p>
</div>
</div>
</div>
</section>
<!-- === SLIDE 5: FOR LOOP === -->
<section>
<h3>for Loop</h3>
<p class="text-small">Digunakan untuk mengulang kode sejumlah kali yang <strong>sudah diketahui</strong>
atau mengiterasi item dalam sequence.</p>
<div class="grid-2">
<div class="card">
<h4>Syntax & Contoh</h4>
<pre><code class="python" data-trim>
# Syntax
for item in iterable:
# Kode yang diulang
# Contoh
for i in range(5):
print(i)
</code></pre>
</div>
<div class="card">
<h4>Output Terminal</h4>
<pre class="code-output" style="line-height: 1.1; margin: 0;">
0
1
2
3
4
</pre>
</div>
</div>
</section>
<!-- === SLIDE 6: RANGE === -->
<section>
<h3>Fungsi range()</h3>
<p class="text-small">Fungsi <code>range()</code> menghasilkan urutan angka yang bisa digunakan dalam loop.
Urutan ini <strong>tidak menyimpan semua angka</strong> di memori (efisien untuk angka besar).</p>
<table class="text-smaller" style="font-size: 0.8em; line-height: 1.1;">
<thead>
<tr>
<th>Syntax</th>
<th>Penjelasan</th>
<th>Contoh</th>
<th>Hasil</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>range(n)</code></td>
<td>Dari 0 sampai n-1</td>
<td><code>range(5)</code></td>
<td><code>0, 1, 2, 3, 4</code></td>
</tr>
<tr>
<td><code>range(start, end)</code></td>
<td>Dari start sampai end-1</td>
<td><code>range(2, 6)</code></td>
<td><code>2, 3, 4, 5</code></td>
</tr>
<tr>
<td><code>range(start, end, step)</code></td>
<td>Dengan loncatan step</td>
<td><code>range(0, 8, 2)</code></td>
<td><code>0, 2, 4, 6</code></td>
</tr>
<tr>
<td><code>range(start, end, -step)</code></td>
<td>Hitung mundur</td>
<td><code>range(10, 0, -2)</code></td>
<td><code>10, 8, 6, 4, 2</code></td>
</tr>
</tbody>
</table>
</section>
<!-- === SLIDE 7: CONTOH FOR LOOP === -->
<section>
<h3>Variasi for Loop</h3>
<div class="grid-2">
<div class="card">
<h4>Hitung Mundur</h4>
<pre><code class="python" data-trim>
for i in range(5, 0, -1):
print(i)
</code></pre>
<h5>Output Terminal</h5>
<div class="code-output" style="margin-top: 10px; font-size: 0.6em;">
5<br>4<br>3<br>2<br>1
</div>
</div>
<div class="card">
<h4>Total Penjumlahan</h4>
<pre><code class="python" data-trim>
total = 0
for i in range(1, 101):
total += i
print(total)
</code></pre>
<h5>Output Terminal</h5>
<div class="code-output" style="margin-top: 10px; font-size: 0.6em;">
5050
</div>
</div>
</div>
</section>
<!-- === SLIDE 8: WHILE LOOP === -->
<section>
<h3>while Loop</h3>
<p class="text-small">Digunakan untuk mengulang kode selama kondisi bernilai <strong>TRUE</strong>.
Jumlah perulangan mungkin tidak diketahui di awal.</p>
<div class="flex-container">
<div class="flex-col">
<pre><code class="python" data-trim>
i = 0
while i < 5:
print(i)
i += 1 # UPDATE KONDISI!
</code></pre>
</div>
<div class="flex-col card">
<p class="text-smaller">Cocok untuk:</p>
<ul class="text-smaller">
<li>Menunggu input user yang valid</li>
<li>Game loop</li>
<li>Membaca file sampai habis</li>
</ul>
</div>
</div>
</section>
<!-- === SLIDE 9: INFINITE LOOP === -->
<section>
<h3><i class="bi bi-exclamation-triangle"></i> Peringatan: Infinite Loop</h3>
<div class="flex-container">
<div class="flex-col card card-success">
<h4><i class="bi bi-check-circle"></i> BENAR</h4>
<pre><code class="python">
i = 0
while i < 5:
print(i)
i += 1 # Ada update
</code></pre>
</div>
<div class="flex-col card card-danger">
<h4><i class="bi bi-x-circle"></i> SALAH (BAHAYA)</h4>
<pre><code class="python">
i = 0
while i < 5:
print(i)
# i tidak berubah
# Loop selamanya!
</code></pre>
</div>
</div>
</section>
<!-- === SLIDE 10: BREAK & CONTINUE === -->
<section>
<h3>break dan continue</h3>
<div class="flex-container">
<div class="flex-col card">
<h4>break</h4>
<p class="text-smaller">Menghentikan loop secara paksa.</p>
<pre><code class="python">
for i in range(10):
if i == 5:
break
print(i)
# Output: 0, 1, 2, 3, 4
</code></pre>
</div>
<div class="flex-col card">
<h4>continue</h4>
<p class="text-smaller">Skip iterasi saat ini, lanjut ke berikutnya.</p>
<pre><code class="python">
for i in range(5):
if i == 2:
continue
print(i)
# Output: 0, 1, 3, 4
</code></pre>
</div>
</div>
</section>
<!-- === SLIDE 11: CONTOH KOMBINASI === -->
<section>
<h3>Contoh: Kalkulator Interaktif</h3>
<pre><code class="python" data-trim style="max-height: 400px; font-size: 0.8em;">
while True:
operasi = input("Operasi (+, -, q=quit): ")
if operasi == 'q':
print("Bye!")
break # Keluar dari while
a = float(input("Angka 1: "))
b = float(input("Angka 2: "))
if operasi == '+':
print(f"Hasil: {a + b}")
elif operasi == '-':
print(f"Hasil: {a - b}")
</code></pre>
</section>
<!-- === SLIDE 12: HANDS ON === -->
<section>
<h3>Hands-On Practice</h3>
<div class="grid-2">
<div class="card">
<h4>1. Faktorial</h4>
<p class="text-smaller">Input: n<br>Output: n! (1 × 2 × ... × n)</p>
<h5>Output Terminal (contoh)</h5>
<div class="code-output" style="margin-top: 10px; font-size: 0.5em;">
5! = 120
</div>
</div>
<div class="card">
<h4>2. Cek Bilangan Prima</h4>
<p class="text-smaller">Input: n<br>Output: "Prima" atau "Bukan Prima"</p>
<h5>Output Terminal (contoh)</h5>
<div class="code-output" style="margin-top: 10px; font-size: 0.5em;">
7 → "Prima"
</div>
</div>
</div>
</section>
<!-- === SLIDE 13: LATIHAN TAMBAHAN === -->
<section>
<h3>Latihan Tambahan</h3>
<div class="grid-2">
<div class="card">
<h4>3. Pola Bintang</h4>
<p class="text-smaller">Input: n (tinggi segitiga)</p>
<h5>Output Terminal (contoh)</h5>
<div class="code-output" style="margin-top: 10px; font-size: 0.5em; line-height: 1.2;">
*<br>**<br>***<br>****<br>*****
</div>
</div>
<div class="card">
<h4>4. Deret Fibonacci</h4>
<p class="text-smaller">Input: n (jumlah bilangan)</p>
<h5>Output Terminal (contoh)</h5>
<div class="code-output" style="margin-top: 10px; font-size: 0.5em;">
0, 1, 1, 2, 3, 5, ...
</div>
</div>
</div>
</section>
<!-- === SLIDE 14: RINGKASAN === -->
<section>
<h3>Ringkasan Hari Ini</h3>
<ul class="text-small">
<li><i class="bi bi-check-circle"></i> <strong>for loop</strong>: Untuk iterasi yang jumlahnya jelas.</li>
<li><i class="bi bi-check-circle"></i> <strong>while loop</strong>: Untuk iterasi berbasis kondisi.</li>
<li><i class="bi bi-check-circle"></i> <strong>range()</strong>: Membuat urutan angka.</li>
<li><i class="bi bi-check-circle"></i> <strong>Flow Control</strong>: <code>break</code> (stop) dan <code>continue</code> (skip).
</li>
</ul>
</section>
<!-- === SLIDE 15: TUGAS UTAMA === -->
<section>
<h3>Tugas Pertemuan 5 <i class="bi bi-list-check"></i></h3>
<div class="card card-warning text-left">
<ol class="text-small">
<li><strong>Hitung Rata-rata:</strong>
<br>Input n angka menggunakan loop, jumlahkan dan bagi n.
</li>
<li><strong>Tabel Perkalian:</strong>
<br>Cetak tabel perkalian 1 sampai n menggunakan nested loop.
</li>
<li><strong>Game Tebak Angka (Limit):</strong>
<br>Sama seperti minggu lalu, tapi maksimal <strong>5x percobaan</strong>. Jika habis, Game Over.
</li>
</ol>
</div>
</section>
<!-- === SLIDE 16: PANDUAN PENGERJAAN === -->
<section>
<h3>Panduan Pengerjaan Tugas</h3>
<div class="card card-info text-left">
<p class="text-small">Untuk memastikan pemahaman perulangan, ikuti langkah-langkah berikut:</p>
<ul class="text-smaller">
<li><strong>Analisis Loop:</strong> Tentukan jenis loop (for/while) dan kondisi yang tepat.</li>
<li><strong>Desain Alur:</strong> Buat pseudocode dengan loop counter dan kondisi berhenti.</li>
<li><strong>Implementasi:</strong> Tulis kode dengan komentar jelas, gunakan range() dan kontrol loop.</li>
<li><strong>Testing:</strong> Jalankan dengan berbagai input untuk memastikan loop bekerja benar.</li>
<li><strong>Refleksi:</strong> Tambahkan cell teks untuk refleksi penggunaan perulangan.</li>
<li><strong>Dokumentasi:</strong> Jelaskan logika loop dan hasil di komentar.</li>
</ul>
</div>
</section>
<!-- === SLIDE 17: PENGUMPULAN TUGAS === -->
<section>
<h3>Pengumpulan Tugas</h3>
<div class="card card-warning text-left">
<div class="flex-container" style="align-items: center;">
<div class="flex-col text-left">
<p class="text-smaller"><strong>Instruksi:</strong></p>
<ul class="text-smaller">
<li>Simpan file: <code>Tugas5_NIM_Nama.ipynb</code></li>
<li>Sertakan komentar dan output contoh di notebook.</li>
<li>Upload ke LMS sebelum deadline.</li>
</ul>
</div>
<div class="flex-col text-center">
<div style="font-size: 3em;"><i class="bi bi-exclamation-triangle"></i></div>
<p class="text-smaller"><strong>Deadline:</strong><br>H-1 Pertemuan Berikutnya</p>
</div>
</div>
</div>
</section>
<!-- === SLIDE 18: NEXT WEEK === -->
<section>
<h3>Pertemuan Berikutnya</h3>
<h4>List (Daftar) <i class="bi bi-list"></i></h4>
<p class="text-small">Kita akan belajar cara menyimpan BANYAK data (seperti rak buku) dalam SATU
variabel.</p>
<pre><code class="python">
buah = ["apel", "jeruk", "mangga"]
print(buah[1]) # jeruk
</code></pre>
</section>
<!-- === SLIDE 19: Q&A === -->
<section>
<h1>Q & A</h1>
<p>Terima Kasih!</p>
<div class="text-smaller" style="margin-top: 50px; color: #666;">
Sampai jumpa! <i class="bi bi-hand-wave"></i>
</div>
</section>
</div>
</div>
<script src="js/theme-toggle.js"></script>
<script src="dist/reveal.js"></script>
<script src="plugin/notes/notes.js"></script>
<script src="plugin/markdown/markdown.js"></script>
<script src="plugin/highlight/highlight.js"></script>
<script>
Reveal.initialize({
hash: true,
progress: true,
center: true,
transition: 'slide',
slideNumber: 'c/t',
plugins: [RevealMarkdown, RevealHighlight, RevealNotes]
});
</script>
<script src="js/emoji-to-icons.js"></script>
<script src="js/auto-layout.js"></script>
<script src="js/slide-enhancements.js"></script>
</body>
</html>