Python math.log()เมธอด
ตัวอย่าง
หาลอการิทึมธรรมชาติของตัวเลขต่างๆ
# 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))
ความหมายและการใช้งาน
วิธี การmath.log()
ส่งคืนลอการิทึมธรรมชาติของตัวเลข หรือลอการิทึมของตัวเลขเป็นฐาน
ไวยากรณ์
math.log(x, base)
ค่าพารามิเตอร์
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' |
รายละเอียดทางเทคนิค
คืนมูลค่า: | ค่า ที่float แทนลอการิทึมธรรมชาติของตัวเลข หรือลอการิทึมของตัวเลขเป็นฐาน |
---|---|
เวอร์ชันหลาม: | เปลี่ยนในเวอร์ชัน 2.3 |
บันทึกการเปลี่ยนแปลง: | เพิ่มพารามิเตอร์พื้นฐาน แล้ว |