# Python | Write functions to find square and cube of a given number

Here, we are going to implement a python program to find square and cube of a given number by creating functions.
Submitted by IncludeHelp, on August 13, 2018

Given a number, and we have to write user defined functions to find the square and cube of the number is Python.

Example:

```    Input:
Enter an integer number: 6

Output:
Square of 6 is 36
Cube of 6 is 216
```

Function to get square:

```def  square (num):
return (num*num)
```

Function to get cube:

```def  cube (num):
return (num*num*num)
```

Program:

```# python program to find square and cube
# of a given number

# User defind method to find square
def square (num):
return  (num*num)

# User defind method to find cube
def cube (num) :
return  (num*num*num)

# Main code
# input a number
number = int (raw_input("Enter an integer number: "))

# square and cube
print "square of {0} is {1}".format(number, square(number))
print "Cube of {0} is {1}".format(number, cube (number))
```

Output

```    Enter an integer number: 6
square of 6 is 36
Cube of 6 is 216
```

Preparation