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
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.