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

रामायण

रामायण दशरथ की तीन पत्नियाँ – कौशल्या, सुमित्रा , कैकेयी दशरथ के चार पुत्र – राम,लक्ष्मण,भरत,शत्रुघ्न दशरथ: राम के पिता और कौशल के राजा कौशल...