Given a list of numbers of list, write a Python program to create a list of tuples having first element as the number and second element as the cube of the number.
Input: list = [1, 2, 3] Output: [(1, 1), (2, 8), (3, 27)] Input: list = [9, 5, 6] Output: [(9, 729), (5, 125), (6, 216)]
We can use list comprehension to create a list of tuples. The first element will be simply an element and second element will be cube of that number.
Below is the Python implementation:
[(1, 1), (2, 8), (5, 125), (6, 216)]
- Python | Remove tuples having duplicate first value from given list of tuples
- Python | Reverse each tuple in a list of tuples
- Python program to find Tuples with positive elements in List of tuples
- Python program to find tuples which have all elements divisible by K from a list of tuples
- Python | Find the tuples containing the given element from a list of tuples
- Python - Filter all uppercase characters Tuples from given list of tuples
- Python | Remove duplicate tuples from list of tuples
- Python | Remove tuples from list of tuples if greater than n
- Python | Count tuples occurrence in list of tuples
- Python | Combining tuples in list of tuples
- Python | Convert string tuples to list tuples
- Python - Convert Tuple value list to List of tuples
- Python | How to Concatenate tuples to nested tuples
- Python | Remove tuple from list of tuples if not containing any character
- Python | Group by matching second tuple value in list of tuples
- Python - Combinations of sum with tuples in tuple list
- Python | Swap tuple elements in list of tuples
- Python - Convert List of Lists to Tuple of Tuples
- Python - Join Tuples to Integers in Tuple List
- Python | Check if element is present in tuple of tuples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.