google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: Python program to create a list of tuples from given list having number and its cube in each tuple

Monday, December 16, 2019

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)] 

No comments:

Post a Comment

शिव भोलेनाथ स्तुति

 जय शिवशंकर, जय गंगाधर, करुणा-कर करतार हरे,   जय कैलाशी, जय अविनाशी, सुखराशि, सुख-सार हरे जय शशि-शेखर, जय डमरू-धर जय-जय प्रेमागार हरे,   जय ...