Basic Programs

If Else Programs

While loop Programs

For loop Programs

List Programs


Python Program to Create three lists of numbers, their squares and cubes in a given range.


This example shows, We have create a three lists of numbers, their squares and cubes in a given range.

Example.py
numbers = []
squares = []
cubes = []

start = int(input("Enter the Starting Value:"))
end = int(input("Enter the Ending Value:"))

for i in range(start, end + 1):
    numbers.append(i)
    squares.append(i**2)
    cubes.append(i**3)

print("numbers: ", numbers)
print("squares: ", squares)
print("cubes  : ", cubes)

Output

Enter the Starting Value : 1
Enter the Ending Value : 8
numbers:  [1, 2, 3, 4, 5, 6, 7, 8]
squares:  [1, 4, 9, 16, 25, 36, 49, 64]
cubes  :  [1, 8, 27, 64, 125, 216, 343, 512]

Prev Next