Articles

Program to find cube of a number in python

Program to find cube of a number in python


In this python program guide, we will learn to write a:

  • program to find cube of a number in python

Python program to find cube of a number

Here we will accept a number from user as int value. We will use ** to calculate cube of the number and store it in a variable. Finally we will print variable on screen.

 

Please check our video tutorial on program to find cube of a number in python:

 

 

Given below we write a program to find cube of a number in python:

 

# Owner : TutorialsInhand Author : Devjeet Roy

number = int(input("Enter the number: "))

cube = number ** 3

print("The cubed value is:",cube)

The output of python code to find cube of a number is:

 

PS C:\Users\DEVJEET\Desktop\tutorialsInHand> python code.py
Enter the number: 3
The cubed value is: 27

Few important points about this program:

1. We take the input from the user using the input() function. We convert the input to its int type using int() function.

2. We do exponential calculations using the "**" operator. The number before the operator denotes the base and the number after the operator denotes the exponent.

 

program to find cube of a number in python snapshot:

python code to find cube of a number

This wraps up our session on program to find cube of a number in python or python program to find cube of a number.


Basic Python Programs

Would you like to see your article here on tutorialsinhand. Join Write4Us program by tutorialsinhand.com

About the Author
Devjeet Roy
Full Stack Web Developer & Blockchain Enthusiast
Page Views :    Published Date : Nov 13,2022  
Please Share this page

Related Articles

Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!