Q:

# Write a python program to rint the cube of all numbers from 1 to a given number

### Calculate the cube of all numbers from 1 to a given number

Write a program to rint the cube of all numbers from 1 to a given number

Given:

`input_number = 6`

Expected output:

```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```

### All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Hint:

• Iterate numbers from 1 to `n` using for loop and `range()` function
• In each iteration of a loop, calculate the cube of a current number (`i`) by multiplying itself three times (`c = i * i* i)`

Solution:

``````input_number = 6
for i in range(1, input_number + 1):
print("Current Number is :", i, " and the cube is", (i * i * i))``````

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)