
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python program to create a list of tuples from the given list having the number and its cube in each tuple
In this article, we will learn about the solution and approach to solve the given problem statement.
Problem statement −Given list input, we need to create a tuple with numbers and their corresponding cubes.
Let’s see the approach to solve the above problem with the help of inline implementation as shown.
Example
list1 = [0,1,2,4,6] res = [(val, pow(val, 3)) for val in list1] # main print(res)
Output
[(0, 0), (1, 1), (2, 8), (4, 64), (6, 216)]
The figure given below shows the declaration of the list and its conversion into a series of nested tuples.
Conclusion
In this article, we learned about the approach to create a list of tuples from the given list having a number and its cube in each tuple.
- Related Articles
- Create a list of tuples from given list having number and its cube in each tuple using Python
- Remove tuples having duplicate first value from given list of tuples in Python
- Reverse each tuple in a list of tuples in Python
- Python program to Sort a List of Tuples in Increasing Order by the Last Element in Each Tuple
- Find the tuples containing the given element from a list of tuples in Python
- Python Program to find the cube of each list element
- Sort a List of Tuples in Increasing Order by the Last Element in Each Tuple using Python program
- Create a tuple from string and list in Python
- Remove Tuples from the List having every element as None in Python
- Python – Remove Tuples from a List having every element as None
- Python Program to Create a List of Tuples with the First Element as the Number and Second Element as the Square of the Number
- Combinations of sum with tuples in tuple list in Python
- How to create a tuple from a string and a list of strings in Python?
- Remove tuple from list of tuples if not containing any character in Python
- Remove duplicate tuples from list of tuples in Python

Advertisements