Write a Python Program to calculate the natural logarithm of any number.

Write a Python Program to calculate the natural logarithm of any number.

Write a Python Program to calculate the natural logarithm of any number.

Natural logarithm

The natural logarithm, often denoted as ln, is is a mathematical function that represents the ogarithm to the base e,where is the mathematical constant approximately equal to 2.71828.In other words, for a positive number x, the natural logarithm of x is the exponent y that satisfies the equation ey=x.
Mathematically, the natural logarithm is expressed as:
ln(𝑥)
It is commonly used in various branches of mathematics, especially in calculus and mathematical analysis, as well as in fields such as physics, economics, and engineering. The natural logarithm has properties that make it particularly useful in situations involving exponential growth or decay.

Program
import math
def myfun():
    num=float(input("Enter a number: "))
    if(num<0):
        print("Please enter a positive number.")
    else:
        result=math.log(num)
        print(f"The natural logarithm of{num} is :{result}")
    
if __name__=="__main__":
    myfun()
         



Output:

Enter a number: 1.4
The natural logarithm of1.4 is :0.3364722366212129



More Questions


81 . Write a Python Program to calculate your Body Mass Index.
82 . Write a Python Program to calculate the natural logarithm of any number.
83 . Write a Python Program for cube sum of first n natural numbers?
84 . Write a Python Program to find sum of array.



For latest job updates join Telegram Channel: https://t.me/sateeshm