Create a list of tuples from a list having a number and its square in each tuple

In this python tuple program, we will create a list of tuples from a list having a number and its square in each tuple.

Steps to solve the program
  1. Take a list as input.
  2. Use the list comprehension method to create a list of tuples from a list having a number and its square in each tuple.
  3. Use for loop to iterate over elements in the list and use pow() to get the square of the elements.
  4. Perform the above operations inside a list to achieve list comprehension.
  5. Print the output.
				
					list1 = [4,6,3,8]

tup = [(val, pow(val, 2)) for val in list1]
print(tup)
				
			

Output :

				
					[(4, 16), (6, 36), (3, 9), (8, 64)]
				
			

find the minimum value from a tuple.

create a tuple with different datatypes.

1 thought on “Create a list of tuples from a list having a number and its square in each tuple”

Leave a Comment