[Python2] Function Procedure
Deklarasi
def Nama_Fungsi(Parameter,paramter,..) :
Body
Contoh Konversi suhu
def segitiga(tinggi,alas):
hasil=(1.0/2)*tinggi*alas
return hasil
print segitiga(3,8)
def fah2cel(fahrenheit):
celcius=(5.0/9)*(fahrenheit-32)
return celcius
print fah2cel(2)
def fah2kel(fahrenheit):
celcius=fah2cel(fahrenheit)
kelvin=celcius+273.15
return kelvin
print fah2kel(2)
def hello():
print "helo kehed"
hello()
Output :
-16.6666666667
256.483333333
helo kehed
4 9
Procedure
#!/usr/bin/python Money = 2000 def AddMoney(): # Uncomment the following line to fix the code: # global Money Money = Money + 1 print Money AddMoney() print Money