Basic Programs

If Else Programs

While loop Programs

For loop Programs

List Programs


Python program to print the Cube of all numbers from 1 to a given number


This examples shows, how to calculate the cube of all numbers from 1 to a given number using for loop.

Example.py
limit = int(input("Enter the Number : "))
for i in range(1, limit + 1):
    print("Current Number is :", i, " and the cube is", (i * i * i))

Output

Enter the Number : 6

Current Number is : 1  and the cube is 1
Current Number is : 2  and the cube is 8
Current Number is : 3  and the cube is 27
Current Number is : 4  and the cube is 64
Current Number is : 5  and the cube is 125
Current Number is : 6  and the cube is 216

Prev Next