Cubed in python – Python Program To Print Cube Number Series 1 8 27 64…N

Cubed in python: In the previous article, we have discussed Python Program to Print Series 6, 9, 14, 21, 30, 41, 54 … N
Given a number N and the task is to print the cube number series (1 8 27 64…N) till the given number N in Python. A cube of number in python using for loop, cubed in python, number series in python, python cube program, cube root in python, python cube of a number, cube a number in python, cubic root python, python cube root are discussed below.

Cube number:

A cube number is a number that has been multiplied by itself three times. This is also known as ‘a number cubed.’ Cubed is represented by the symbol ³.

For example :

The cube number of 3= 3³ =3*3*3 = 27.

Examples:

Example1:

Input:

Given Number (Limit) = 8

Output:

The above cube series till the given number{ 8 } is :
1 8 27 64 125 216 343 512

Example2:

Input:

Given Number (Limit) = 6

Output:

The above cube series till the given number{ 6 } is :
1 8 27 64 125 216

Program To Print Cube Number Series 1 8 27 64…N in Python

Below are the ways to print the cube number series (1 8 27 64…N) till the given number N in Python:

Method #1: Using While Loop (Static Input)

Approach:

  • Give the number N (Limit) as static input and store it in a variable.
  • Take a variable to say itr and initialize its value to 1.
  • Loop until the above-declared variable itr value is less than or equal to the given number using the while loop.
  • Inside the while loop, multiply the itr with itself 3 times and store it in another variable.
  • Print the above result separated by spaces.
  • Increment the above itr value by 1.
  • The Exit of the Program.

Below is the implementation:

# Give the number N(limit) as static input and store it in a variable.
gvn_numb = 8
# Take a variable to say itr and initialize its value to 1.
itr = 1
print("The above cube series till the given number{", gvn_numb, "} is :")
# Loop until the above-declared variable itr value is less than or equal to the
# given number using the while loop.
while(itr <= gvn_numb):
    # Inside the while loop, multiply the itr with itself 3 times and store it in
    # another variable.
    k = itr*itr*itr
    # Print the above result separated by spaces.
    print(k, end=" ")
    # Increment the above itr value by 1.
    itr += 1

Output:

The above cube series till the given number{ 8 } is :
1 8 27 64 125 216 343 512

Method #2: Using While loop (User Input)

Approach:

  • Give the number N (Limit) as user input using the int(input()) function and store it in a variable.
  • Take a variable to say itr and initialize its value to 1.
  • Loop until the above-declared variable itr value is less than or equal to the given number using the while loop.
  • Inside the while loop, multiply the itr with itself 3 times and store it in another variable.
  • Print the above result separated by spaces.
  • Increment the above itr value by 1.
  • The Exit of the Program.

Below is the implementation:

# Give the number N (Limit) as user input using the int(input()) function and 
# store it in a variable.
gvn_numb = int(input("Enter some Random Number = "))
# Take a variable to say itr and initialize its value to 1.
itr = 1
print("The above cube series till the given number{", gvn_numb, "} is :")
# Loop until the above-declared variable itr value is less than or equal to the
# given number using the while loop.
while(itr <= gvn_numb):
    # Inside the while loop, multiply the itr with itself 3 times and store it in
    # another variable.
    k = itr*itr*itr
    # Print the above result separated by spaces.
    print(k, end=" ")
    # Increment the above itr value by 1.
    itr += 1

Output:

Enter some Random Number = 6
The above cube series till the given number{ 6 } is :
1 8 27 64 125 216

The best way to learn Python for Beginners is to practice as much as they can taking help of the Sample Python Programs For Beginners. Using them you can develop code on your own and master coding skills.

Also Refer: Python Program to Print Series 1 2 5 8 15 28 51 94….N

Practice these: 

  1. print the following series using for loop:- 1,8,27,64,125,216,……n
  2. write a python program to print the series 1,8,27,64,125……n
  3. print the following series using for loop:- 1,8,27,64,125,216,……n input 125 output :- 1 8 27 64 125
  4. 1 – 8 – 27 – ? – 125 – 216
  5. 1, 8, 27, 64, 125, 216, 343,a. 1 8 27 64 sequence
    b. 1 8 27 125 216
    c.1 8 27 64 125 216
    d. 1 8 27 64 series
    e. pattern 1 8 27 64?
  6. write a program to print following series 1 8 27 64

Related Posts On: