import math
print(math.log10(2)) # 0.3010299956639812
print(math.log10(4)) # 0.6020599913279624
print(math.log10(5)) # 0.6989700043360189
Using negative number import math
print(math.log10(-2))
print(math.log10(0))
Above code will generate error. import math
num = 1000
print("log10(1000):", math.log10(num)) # Base 10 log :Output 3.0
print("log(1000):", math.log(num)) # Base e log :6.907755278982137
print("log2(1000):", math.log2(num)) # Base 2 log : 9.965784284662087
Scientific Notation:richter_scale = math.log10(1000)
print(f"Richter scale magnitude: {richter_scale}")
Output
Richter scale magnitude: 3.0
import math
print(math.log10(100)) # Output: 2.0
print(math.log10(1000)) # Output: 3.0
import math
try:
print(math.log10(-10))
except ValueError as e:
print("Error:", e)
Output:
Error: math domain error
data = [1, 10, 100, 1000, 10000]
log_data = [math.log10(x) for x in data]
print(log_data)
Output:
[0.0, 1.0, 2.0, 3.0, 4.0]
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.