I am new to Python. I wish to write a function in python that calculates a square or a cube or any other power of a number? How to do it ? Jul 2 in Python 32 views

## 1 answer to this question.

Yes you can do it using the math library in Python

import math
x = math.pow(2,3) # x = 2 to the power of 3
print(x)

You can include the above code in a function and then call the function. answered Jul 2 by
• 2,960 points

## How to calculate square root of a number in python?

calculate square root in python >>> import math ...READ MORE

–1 vote

## How to find the size of a string in Python?

following way to find length of string  x ...READ MORE

## How to filter out any digit that contains odd number in a range of number in Python?

n = list(range(10)) b = list(filter(lambda i:i%2!=0,n)) print(b) READ MORE

## How do I find out the sum of digits of a number in Python?

Hi, good question. If you are considering ...READ MORE

## how do i change string to a list?

suppose you have a string with a ...READ MORE

+1 vote

## how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

## how do i use the enumerate function inside a list?

can you give an example using a ...READ MORE