;

Python Program to Calculate Cube of a Number


Tutorialsrack 25/04/2020 Python

In the Python program, we will learn how to calculate the Cube of a Number. 

Here is the source code of the program to calculate the Cube of a Number. 

Program 1: Python Program to Calculate Cube of a Number

Python Program to Calculate Cube of a Number
# Python Program to Calculate Cube of a Number

#To take input from user
number = float(input("Enter any numeric Value: "))

cube = number * number * number

print("The Cube of a Given Number {0}  = {1}".format(number, cube))
Output

Enter any numeric Value: 5

The Cube of a Given Number 5.0  = 125.0

Program 2: Python Program to Calculate Cube of a Number using Exponent Operator

Python Program to Calculate Cube of a Number using Exponent Operator

# Python Program to Calculate Cube of a Number using Exponent Operator

#To take input from user
number = float(input("Enter any numeric Value: "))

cube = number ** 3

print("The Cube of a Given Number {0}  = {1}".format(number, cube))
Output

Enter any numeric Value: 3

The Cube of a Given Number 3.0  = 27.0


Related Posts



Comments

Recent Posts
Tags