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
    • Go Programs
    • Python Programs
    • Java Programs

Python pow

by suresh

The Python pow function is used to calculate the Power of the specified expression. The syntax of the Python math pow Function is

math.pow(base, Exponent);
  • Base: Please specify the base value here.
  • Exponent: Please specify the Exponent value or power here.

For example, if x is base value and 2 is exponent, then the Math.pow(x, 2) = x²

NOTE: If the Base value or Exponent value argument is not a number, pow function returns TypeError.

Python pow Function Example

The Python pow function returns the Power of the given number. In this pow example, we are going to find the power of different data types and display the output

# Python POW Function

import math

Tup = (10.98, 20.26, 12.05, -40.95 , 50.45) # Tuple Declaration
Lis = [-10.98, 32.65, -39.59, -42.15 , 15.97] # List Declaration

print('Calculating Power of Positive Number = %.2f' %math.pow(2, 3))
print('Calculating Power of Negative Number = %.2f' %math.pow(-2, 3))
print('Calculating Power of String Number = ', math.pow(2, -3))

print('Calculating Power of of Tuple Item = %.2f' %math.pow(Tup[2], 2))
print('Calculating Power of List Item = %.2f' %math.pow(Lis[4], 4))

print('Calculating Power of Multiple Number = %.2f' %math.pow(1 + 2 - 12.65, 2))

print('Calculating Power of String Value = ', math.pow('2', 3))
Python POW Function
  1. Within the first three statements, We passed both the Positive integer and negative integer as the Python math pow Function arguments. From the above screenshot, you can observe that the pow Function is returning output.
  2. Next, We used the Tuple and List items as base arguments and integer value as an exponent for pow Function. If you see the above Python image, the Math function is working correctly on them.
  3. We assigned multiple values as base arguments for pow Function.
  4. Last, We tried pow Function on the String value, and it returns TypeError.

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 Function
  • Python Functions
  • Python Types of Functions
  • Python Iterator
  • Python File Handling
  • 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

Copyright © 2021· All Rights Reserved.
About | Contact | Privacy Policy