# math.pow() method with example in Python

Python math.pow() method: Here, we are going to learn about the math.pow() method with example in Python.
Submitted by IncludeHelp, on April 18, 2019

## Python math.pow() method

math.pow() method is a library method of math module, it is used to calculate the given power of a base, it accepts two numbers and returns the first number to the power of the second number in the float.

Syntax of math.pow() method:

```    math.pow(a, b)
```

Parameter(s): a, b – the numbers whose power needs to be calculated (Here, a is the base and b is the power to calculate the result a to the power of b).

Return value: float – it returns a float value that is the a to the power of b.

Example:

```    Input:
a = 2
b = 3

# function call
print(math.pow(a, b))

Output:
8.0
```

### Python code to demonstrate example of math.pow() method

```# python code to demonstrate example of
# math.pow() method

# importing math module
import math

# numbers
a = 2
b = 3
# calculate a to the power of b
print(a, " to the power of ", b, " is = ", math.pow(a,b))

# numbers
a = 2.2
b = 3.0
# calculate a to the power of b
print(a, " to the power of ", b, " is = ", math.pow(a,b))

# numbers
a = 2
b = 0
# calculate a to the power of b
print(a, " to the power of ", b, " is = ", math.pow(a,b))

# numbers
a = 0
b = 3
# calculate a to the power of b
print(a, " to the power of ", b, " is = ", math.pow(a,b))
```

Output

```2  to the power of  3  is =  8.0
2.2  to the power of  3.0  is =  10.648000000000003
2  to the power of  0  is =  1.0
0  to the power of  3  is =  0.0
```

TOP Interview Coding Problems/Challenges

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates