Python tuple program to swap the tuples

In this python tuple program, we will swap the tuples.

Steps to solve the program
  1. Take two tuples as input.
  2. Swap the tuples by using the  ” operator i.e. a,b=b,a.
  3. Print the output.
				
					A=(7,4,9)
B=(3,)
print(f"tuple1: {A}, tuple2: {B}")
A,B = B,A
print(f"tuple1: {A}, tuple2: {B}")
				
			

Output :

				
					tuple1: (7, 4, 9), tuple2: (3,)
tuple1: (3,), tuple2: (7, 4, 9)
				
			

calculate the average of the elements in the tuple.

check the type of the input and return True if the type is a tuple and False if it is not a tuple.

Leave a Comment