Python program to create a list of tuples from given list having number and its cube in each tuple

Write a python program to create a list of tuples from given list having number and its cube in each tuple:


Answer:

list1 = [1, 2, 7, 8]
res = [(val, pow(val, 3)) for val in list1]
print(res)

Output:
[(1, 1), (2, 8), (7, 343), (8, 512)] 

Comments

Popular posts from this blog

Solve

Solved practical slips of 12th Computer Science journal

SOLVE QUESTION ANSWERS ON OPERATING SYSTEM .