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.

**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.

- Python Program to Print Series 2, 4, 7, 12, 21, … N
- Python Program to Print Series 1, 3, 7, 15, 31 … N
- Python Program to Print Series 1, -2, 6, -15, 31 … N
- Python Program to Print Series 6, 9, 14, 21, 30, 41, 54 … N