Printing Square and Cube values in Python

Simple Python Script to Print the Square and Cube values for first 10 numbers. It can be done by using the for loop in python. We will iterate from 1 to 11 and print the multiplied values eg. x*x for square and x*x*x for cube.

Source code :

count = 11      # ranges are user defined

for x in range(1,count):   
    print '%d %d %d' %(x, x*x, x*x*x)


Output :

1 1 1
2 4 8
3 9 27
4 16 64
5 25 125
6 36 216
7 49 343
8 64 512
9 81 729
10 100 1000

Output :


                

Comments :