Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs
    • SQL FAQ’s

Python log10

by suresh

The Python log10 function is one of the Python Math functions that calculate the logarithmic value of a given number of base 10. In this section, we discuss how to use log10 function in Python Programming language with example.

This Python log10 function is more accurate than math.log(x, 10). The syntax of the log10 Function in Python Programming Language is

math.log10(number);

Number: A valid numeric expression and

  • If the number argument is a positive number, the log10 function returns the output.
  • If the number argument is Zero or Negative number, log10 function returns ValueError.
  • And if it is not a number, log10 function return TypeError.

Python log10 Function Example

The Python log10 Function calculates the logarithmic value of a given number of base 10. In this log10 example, We find the base 10 logarithmic value of different data types and display the output.

# 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

Python LOG10 Function

ANALYSIS

  1. Within the first two statements, We used the log10 Function directly on Positive integer and Decimal values.
  2. Next two statements, We used the log10 Function on Python Tuple and Python List items. If you observe the above Python screenshot, this Math function is calculating the logarithm value of base 10.
  3. Next statement, We tried log10 Function directly on multiple values
  4. Next, We tried log10 Function on the String value, and it returns TypeError: a float is required as output
  5. Then, We tried log10 Function on Negative value. As we said before, this is returning ValueError: math domain error as output
  6. Last, We tried log10 Function on Zero value. As we said before, this is returning ValueError: math domain error as output.

Please refer to the Python log article to understand the Python log function.

Placed Under: Python

  • Download and Install Python
  • Python Arithmetic Operators
  • Python Assignment Operators
  • Python Bitwise Operators
  • Python Comparison Operators
  • Python Logical Operators
  • Python If Statement
  • Python If Else
  • Python Elif Statement
  • Python Nested If
  • Python For Loop
  • Python While Loop
  • Python Break
  • Python Continue
  • Python Dictionary
  • Python datetime
  • Python String
  • Python Set
  • Python Tuple
  • Python List
  • Python List Comprehensions
  • Python Lambda
  • Python Functions
  • Python Types of Functions
  • Python Iterator
  • Python File
  • Python Directory
  • Python Class
  • Python classmethod
  • Python Inheritance
  • Python Method Overriding
  • Python Static Method
  • Connect Python and SQL Server
  • Python SQL Create DB
  • Python SQL Select Top
  • Python SQL Where Clause
  • Python SQL Order By
  • Python SQL Select Statement
  • Python len Function
  • Python max Function
  • Python map Function
  • Python print Function
  • Python sort Function
  • Python range Function
  • Python zip Function
  • Python Math Functions
  • Python String Functions
  • Python List Functions
  • Python NumPy Array
  • NumPy Aggregate Functions
  • NumPy Arithmetic Operations
  • Python Numpy Bitwise operators
  • Numpy Comparison Operators
  • Numpy Exponential Functions
  • Python Numpy logical operators
  • Python Numpy String Functions
  • NumPy Trigonometric Functions
  • Python random Array
  • Python Numpy concatenate
  • Python Numpy Array shape
  • Python Pandas DataFrame
  • Pandas DataFrame plot
  • Python Series
  • Python matplotlib Histogram
  • Python matplotlib Scatter Plot
  • Python matplotlib Pie Chart
  • Python matplotlib Bar Chart
  • Python List Length
  • Python sort List Function
  • Python String Concatenation
  • Python String Length
  • Python Substring
  • Python Programming Examples
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy