w4 Function Procedur
w4 Function Procedur
w4 Function Procedur
9/8/2019 1
Outline
List in python
So, for every procedure we need to define initial state before instructions
from procedure is done and final state that is wished after instructions in
procedure have been done.
After you define the procedure / function and then you want to
perform that procedure, so you can call the procedure / function.
Using procedure / function you can reuse same task multiple times,
easy to understand, easy to write, easy to test, and easy to fix/debug.
jumlah ← 0 { inisiasi }
for k ← 1 to N do
read(x)
jumlah ← jumlah + x
endfor
u ← jumlah/N
The easiest way to create and use procedure is by defining the procedure in
same file with the main program.
Example:
def greet_user():
“””Display a simple greeting.””” This is Example of calling
print(“hello”) procedure
greet_user();
IEH2B3 | Algoritma dan Pemrograman Komputer 10
Parameter and Argument
Parameter is a piece of information the function needs to do its job.
Example of Argument
Registration.py
Import student
student.add_student_to_class(“budi”,”1134849504”)
IEH2B3 | Algoritma dan Pemrograman Komputer 12
List in Python
List in python or know as Array in other language is an identical variable
that arranged in rows so that the address are linked and contiguous.
>>> list[2]
Buatlah program yang memiliki 4 menu yaitu menu input, menu lihat nilai maksimum,
lihat nilai minimum dan keluar.
• Menu input akan menambahkan elemen ke dalam list
• Menu maksimum merupakan prosedur untuk mencari nilai maksimum dalam list
• Menu minimum merupakan prosedur untuk mencari nilai minimum dalam list
• Menu keluar digunakan untuk mengakhiri program