The Python LOG10 function is one of the Python Math function which is used to calculate the logarithmic value of given number of base 10. In this article we will show you, How to use LOG10() function in Python Programming language with example.

**TIP:** This function is more accurate than math.log(x, 10). Please refer Python LOG article to understand the log function.

## Syntax of a Python LOG10 Function

The basic syntax of the LOG10 Function in Python Programming Language is as shown below:

Math.log10(number);

**Number:** It can be a number or a valid numerical expression.

- If the
*number*argument is positive number, LOG10() function will return the output. - If the
*number*argument is Negative number, LOG10() function will return**ValueError** - If the
*number*argument is not a number, LOG10() function will return**TypeError.** - If the
*number*argument is, LOG10() function will return**Zero****ValueError**

### Python LOG10 Function Example

The Python LOG10 Function is used to calculate the logarithmic value of given number of base 10. In this example, We are going to check the same with different data types and display the output

**PYTHON CODE**

# Python LOG10 Function import math Tup = (1, 2, 3, -4 , 5) # Tuple Declaration Lis = [-1, 2, -3.5, -4 , 5] # List Declaration print('Logarithm value of Positive Number = %.2f' %math.log10(1)) print('Logarithm value of Positive Decimal = %.2f' %math.log10(2.5)) print('Logarithm value of Tuple Item = %.2f' %math.log10(Tup[2])) print('Logarithm value of List Item = %.2f' %math.log10(Lis[4])) print('Logarithm value of Multiple Number = %.2f' %math.log10(2 + 7 - 5)) print('Logarithm value of String Number = ', math.log10('Hello'))

**OUTPUT**

**ANALYSIS**

- At the beginning, We declared Python List and Tuple with some random values.
- Within the first two statements, We used the LOG10() Function directly on Positive integer and Decimal values.
- Next two statements, We used the LOG10() Function on Python Tuple and List items. If you observe the above screenshot, LOG10() function is calculating the logarithm value of base 10.
- Next statement, We tried LOG10() Function directly on multiple values
- Next statement, We tried LOG10() Function on String value. As we said before, this will return TypeError: a float is required as output
- Next, We tried LOG10() Function on Negative value. As we said before, this is returning ValueError: math domain error as output
- Last, We tried LOG10() Function on Zero value. As we said before, this is returning ValueError: math domain error as output

Thank You for Visiting Our Blog