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

Python / Decision Making of Python

901

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

Program:

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

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.


This Particular section is dedicated to Programs only. If you want learn more about Python. Then you can visit below links to get more depth on this subject.