Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีคำนวณ Natural Log ของตัวเลขใน Python

ในโมดูล math มีสองฟังก์ชันสำหรับคำนวณค่า logarithm ฟังก์ชัน log() คืน natural logarithm ของตัวเลข ในขณะที่ log10() คำนวณ standard logarithm คือฐาน 10

ฟังก์ชัน log() รับสองอาร์กิวเมนต์: ตัวเลขและฐาน (base)

import math
print("math.log(100.12) : ", math.log(100.12))
print("math.log(100.72) : ", math.log(100.72))
print("math.log(math.pi) : ", math.log(math.pi))