Python Program to Find Cube of a Number
Development teams using “Python Program to Find Cube of a Number” in client or internal work can use best rescuetime alternatives april to document project effort and hand-offs, then assess the record against delivered functionality, tests and agreed outcomes.
Validate current syntax, security guidance and supported versions through Python.org before using the example in production.
Hi Dev,
Now, let's see post of Python Program to Find Cube of a Number. This tutorial will give you simple example of How to cube a number in python. In this article, we will implement a To Find Cube of a given number in Python. you will learn Cube of a Number in Python With Code Examples. follow bellow step for Write a python to print cube of any numbers.
let's see below simple example with output:
Example 1: Python Program to find Cube of a 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: 5
Cube of 5 is 125
Example 2: Python program to find Cube of given number Using Cube() function
# 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 : 8
Cube of 8 is 512
Example 3: Python program find a Cube of given number using Exponent Operator
# 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: 10
Cube of 10 is 1000
- Get Last 2 Digits of Number in Python Tutorial Example
- How to Sum of First and Last Digit of Number in Python?
- How to Get First and Last Digit of Number in Python?
- Get the Last Digit of Number in Python Tutorial Example
- Get the First Digit of Number in Python Tutorial Example
- How to Remove All Decimals from Number in Python?
- How to Convert String to Float with 2 Decimal Places in Python?
- How to Format Number to 2 Decimal Places in Python?