Python program to find cube of a number; In this tutorial, you will learn how to find or calculate cube of a number in python using function, exponent operator.
Python Program to Calculate Cube of a Number
- Python Program to find Cube of a Number
- Python program to find Cube of given number Using Cube() function
- Python program find a Cube of given number using Exponent Operator
Now let’s see each one by one:
1: Python Program to find Cube of a Number
- Take input number from the user
- Calculate the cube of given number using * operator
- Print cube of the given number
# Python program to calculate cube of given number
# take input a number from user
num = int(input("Enter an any number: "))
# calculate cube using * operator
cb = num*num*num
# display result
print("Cube of {0} is {1} ".format(num, cb))
Output
Enter an any number: 10 Cube of 10 is 1000
Recommended:-Python Program to Print Star Pattern
2: Python program to find Cube of given number Using Cube() function
- Take input number from the user
- Calculate the cube of the given number using function
- Print cube of the given number
# Python Program to Calculate Cube of a Number
def cube(num):
return num * num * num
num = int(input("Enter an any number : "))
cb = cube(num)
print("Cube of {0} is {1}".format(num, cb))
Output
Enter an any number : 6 Cube of 6 is 216
Recommended:-Python Program to Print ASCII Value of Character
3: Python program find a Cube of given number using Exponent Operator
- Take input number from the user
- Calculate the cube of given number using Exponent Operator
- print cube of the given number
# Python program to calculate cube of a number using Exponent Operator
# take input from user
num = int (input("Enter an any number: "))
# calculate cube using Exponent Operator
cb = num**3
# print
print("Cube of {0} is {1} ".format(num, cb))
Output
Enter an any number: 5 Cube of 5 is 125
Recommended Python Posts
Recommended:-Zip Zap Zoom Python Program
Recommended:-Python: program to convert Celsius to Fahrenheit
Recommended:-Python Program to Swap Two Numbers
Recommended:-Python Program to Get Standard Deviation
Recommended:-Python Program to Find the Variance
Recommended:-Python Program to Find Perfect Number
Recommended:-Python: Program to Find Strong Number
Recommended:-Python Program Create Basic Calculator
Recommended:-Python Program For math.floor() Method
Recommended:-Python Program to Find Roots of Quadratic Equation
Recommended:-Python Program to Draw a Pie Chart
Recommended:-Python Program to Calculate Area of Triangle
Recommended:-Python Program to Calculate the Area of a Rectangle