Computer Science, asked by yashika1414, 7 months ago

input a number.find the square and cube of the number in python​

Answers

Answered by rajsidhant
2

Answer:

mark me brainlist pls full explanation

Explanation:

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

Similar questions