Python math.log() Metode
Contoh
Temukan logaritma natural dari berbagai bilangan
# Import math Library
import math
# Return the natural logarithm
of different numbers
print(math.log(2.7183))
print(math.log(2))
print(math.log(1))
Definisi dan Penggunaan
Metode math.log()
ini mengembalikan logaritma natural dari suatu bilangan, atau logaritma bilangan ke basis.
Sintaksis
math.log(x, base)
Nilai Parameter
Parameter | Description |
---|---|
x | Required. Specifies the value to calculate the logarithm for. If the value is 0 or a negative number, it returns a ValueError. If the value is not a number, it returns a TypeError |
base | Optional. The logarithmic base to use. Default is 'e' |
Detail Teknis
Nilai Kembali: | Nilai float , yang mewakili logaritma natural dari suatu bilangan, atau logaritma bilangan ke basis |
---|---|
Versi Python: | Berubah di versi 2.3 |
Ubah Log: | Parameter dasar ditambahkan |