Take a range i.e. start and end, and we have to create three lists, list1 should contains numbers, list2 should contain squares of the numbers and list3 should contain cubes of the numbers in Python.
Example:
Input:
Start = 1
End = 10
Output:
numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
squares: [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
cubes : [1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
Logic:
- Declare three lists.
- Define range, here we are defining start with 1 and end with 10.
- Run a loop with the range as range(start, end+1) and loop counter as count.
- Append the loop counter count to the list named numbers, append square to the list named squares and append the cube to the list named cubes.
- Finally, print the lists.
Program:
Output
By defining own functions
Output
need an explanation for this answer? contact us directly to get an explanation for this answer