# 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

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions

**Ad:**
Are you a blogger? Join our Blogging forum.