Home / Programs / Write a program to print cubes of numbers in the range 10 to 18
🚀 Programming Example

Write a program to print cubes of numbers in the range 10 to 18

👁 415 Views
💻 Practical Program
📘 Step Learning

Write a program to print cubes of numbers in the range 10 to 18

📌 Information & Algorithm

Here is a Python program to print the cubes of numbers in the range 10 to 18:

💻 Program Code

 for num in range(10, 19):
    cube = num ** 3
    print("The cube of", num, "is", cube)
                        

🖥 Program Output

The cube of 10 is 1000
The cube of 11 is 1331
The cube of 12 is 1728
The cube of 13 is 2197
The cube of 14 is 2744
The cube of 15 is 3375
The cube of 16 is 4096
The cube of 17 is 4913
The cube of 18 is 5832

                            

📘 Explanation

In this program, we use a for loop to iterate over the range of numbers from 10 to 18 (inclusive). For each number in the range, we calculate its cube by raising it to the power of 3 using the ** operator, and then we print out the result using the print() function.

This program demonstrates the sequential flow of execution in Python, where the statements are executed in the order in which they appear in the code. The for loop causes the statements inside the loop (i.e., the calculation of the cube and the printing of the result) to be executed repeatedly for each number in the specified range.

📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.