# belajar module from function import say_hello from function import total hello = say_hello("eko") print (hello) hasil = total(1,2,3,4,5,6,7,8,9) print(hasil)
# Belajar Module # 1. import function # 2. from function import say_hello/function from function import say_hello from function import total hello = say_hello("Kien") print(hello) hasil = total(1, 2, 3, 4, 5) print(hasil)
# jika import nama fungsi/nama file aja maka saat dipanggil perlu dipanggel dengan nama fungsi/nama file.nama method import function hello = function.say_hello("Eko") print(hello) hasil = function.total(1, 2, 3) print(hasil) # jika ingin memnaggil dengan nama method aja tanpa disertai fungsi maka # diimport dengan sebagai berikut from function import say_hello from function import total hello = say_hello("Budi") print(hello) hasil = total(1, 2, 3, 5) print(hasil)
#import modul / file lain import function import dir1.function1 as func1 #jika ingin import fungsi tertentu from function import total from function import say_hello #built in module import platform hello = function.say_hello("naufal") print(hello) print(total(1, 2, 3)) print(platform.system()) print(func1.say_hello1("azwar"))
# Belajar Module # Karena tidak mungkin membuat program dalam 1 file # Maka Module dapat memecahnya jadi beberapa file # Mengambil semua method di file function import function hello = function.say_hello("Mas") print(hello) hasil = function.total(1,2,3,4,5) print(hasil) # Untuk mengambil 1 atau 2 method saja # Jika ada banyak method dalam satu file from function import say_hello from function import total # Tidak perlu menambahkan prefix nama modulenya hello = say_hello("Mas") print(hello) hasil = total(10,20,30,40,50) print(hasil)
# Belajar Module from function import say_hello from function import total hello = say_hello("Eko") print(hello) hasil = total(1, 2, 3, 4, 5) print(hasil)