Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

write a program to accept a list and print another list with the cubes of the elements of first list.

–4 votes
asked Oct 6, 2019 by Siddhant Rath (90 points)

2 Answers

0 votes
answered Oct 7, 2019 by dboyd42 (140 points)
#!/usr/bin/env python3
# Author: David Boyd
# Description:
#     This program to accepts a list then prints another list with the cubes of
#     the elements of first list.
# Date: 2019/10/06

def main():

    # Declare variables
    roots = 10
    size = roots+1
    rootls = []
    squaredls = []

    # Create a list of numbers
    for i in range(size):
        rootls.append(i)

    # Square rootls
    for i in range(size):
        squared_num = i*i
        squaredls.append(squared_num)

    # Print lists
    print("Root\t| Square")
    print("================")
    for i in range(size):
        print(rootls[i], "\t|", squaredls[i])

# End Program
main()
0 votes
answered Oct 9, 2019 by gameforcer
def cube_list(l:list):
    return list(map((lambda x: x**3), l))

lst = [1, 2, 3, 4]
print(cube_list(lst))
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...