Summary of "FEB BISDI UNPAD - Pemrograman Komputer 1 - #11 - 13 May 2026"
Main ideas / lessons
-
Recursion concept
- Recursion is a method where a function calls itself.
- It works by:
- “Progressing down” toward a base case
- Then “returning back up” while computing the final answer
- Key tradeoff:
- Recursion can simplify code when a pattern exists
- But it may use more memory, since repeated self-calls create a call stack
-
Exponentiation via iteration vs recursion
- Iterative/manual idea: compute (a^b) by multiplying (a) by itself b times (e.g., a loop with b steps).
- Recursive idea: reduce the exponent:
- (a^b = a \times a^{b-1})
- Base case: if (b = 0), return 1 (since anything to the power 0 equals 1)
- The return values drive the recursion:
- The base case returns 1
- Then each returning call multiplies by (a) to build the result
-
Factorial via iteration vs recursion
-
Factorial definition: [ n! = 1 \times 2 \times 3 \times \dots \times n ]
-
Iterative: use a loop accumulating the product.
- Recursive:
- Base case: if (n = 0), return 1
- Recursive step: (n! = n \times (n-1)!)
- Again, the “count down then return up” pattern is emphasized.
-
-
Fibonacci sequence
- The sequence rule: the next value is the sum of the two previous values:
- (F(n) = F(n-1) + F(n-2))
- Practical concerns discussed:
- A base case (commonly (F(0)=0), (F(1)=1))
- Correct indexing so the code doesn’t go negative or break
- Approaches contrasted:
- Iterative: typically uses a list (or stored variables) to keep previously computed terms
- Recursive: avoids a list, but can repeatedly recompute values (conceptually recursive, but slower)
- The sequence rule: the next value is the sum of the two previous values:
-
GUI introduction with Tkinter
- The lecture transitions to Tkinter GUI development in Python.
- Core GUI structure:
- A root object acts as the main container (window)
- Add widgets (e.g., Label, Button, Entry) to the root
mainloop()runs the GUI event loop (the program waits for user interactions)
- Common Tkinter widgets mentioned:
- Label (text)
- Entry (single-line input)
- Text (multi-line text)
- Frame (group widgets into sections/panels)
- Checkbutton (checkbox; independent options)
- Radiobutton (select exactly one option from a group)
- Listbox / Combobox (select from a list / dropdown)
- Scale / Spinbox (adjustable numeric input)
- Canvas (drawing area)
- Also mentions menus and message boxes
- Layout:
- Starts with pack for placement
- Later mentions grid for structured row/column layout
-
Mini GUI examples
- Name input + submit
- An Entry collects text
- A Button triggers an action that prints the entered value
- Login UI
- User enters username and password
- Button checks them against expected values
- If correct: shows “login correct” / access message
- If incorrect: shows “login incorrect”
- Mentions password masking (displayed as “stars”)
- Name input + submit
Methodologies / instruction-like content (detailed bullets)
A) Recursive power / exponentiation
- Define a conceptual function like
power(a, b) - Base case
- If
b == 0, return1
- If
- Recursive case
- Otherwise return:
a * power(a, b-1)
- Otherwise return:
- Ensure the recursion logic:
- Decreases the exponent each call (
b-1) - Uses returned values to build the final answer while unwinding the call stack
- Decreases the exponent each call (
B) Recursive factorial
- Define a function like
factorial(n) - Base case
- If
n == 0, return1
- If
- Recursive case
- Otherwise return:
n * factorial(n-1)
- Otherwise return:
- Computation pattern:
- Counts down to 0
- Returns up multiplying along the way until reaching the original
n
C) Iterative factorial (contrasted)
- Initialize a running result
r = 1 - Loop from
i = 1ton:- Update
r = r * i
- Update
- Print or return
r
D) Fibonacci (conceptual implementation steps)
- Decide whether to generate:
- A fixed count of terms (e.g., 10 terms), or
- The nth term
- Recurrence
- (F(n) = F(n-1) + F(n-2))
- Base cases
- Handle small (n) (commonly
n==0andn==1)
- Handle small (n) (commonly
- Iterative approach (speaker’s “list” idea)
- Start with a list like
[0, 1] - Append
fib[i-1] + fib[i-2]until you reach the desired position/count
- Start with a list like
- Recursive approach (speaker’s “no list needed” idea)
- Use recursion directly with base cases
- Expect repeated recomputation and higher cost
E) Tkinter GUI structure and widget setup
- Install/enable Tkinter (the lecture mentions platform-specific issues like Replit/Colab)
- Basic Tkinter skeleton:
- Import Tkinter
- Create
root(main window) - Set
root.title(...) - Add widgets (e.g.,
Label,Entry,Button) toroot - Arrange widgets using
pack(in the intro) - Define button actions using
command=...callbacks - Call
root.mainloop()to start the GUI loop
- Widget usage patterns:
- Button
- Without
command, the button does nothing - With
command, it triggers a function when clicked
- Without
- Entry
- Use
entry.get()inside the callback to retrieve user input
- Use
- Frame
- Group widgets into containers for cleaner layout
- Button
F) Mini login logic (GUI callback)
- Create username and password entries
- On submit button click:
- Read inputs using
username_entry.get()andpassword_entry.get() - Compare them to expected values
- Print success/failure messages accordingly
- Read inputs using
Speakers / sources featured (as identifiable from subtitles)
- No specific named person is clearly identified in the subtitles (the speaker is referred to as “ma’am” at times, but no proper name is given).
- Source referenced: ChatGPT (mentioned as assistance/tool in the lecture).
Category
Educational
Share this summary
Is the summary off?
If you think the summary is inaccurate, you can reprocess it with the latest model.
Preparing reprocess...