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.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
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)
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
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()
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
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))
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
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.
...