Computer Science, asked by macshubham9968, 10 months ago

Write a program to input any two tuples and interchange the tupel values.

Answers

Answered by NirmalPandya
9

tuple_1 = eval(input('Enter tuple one: '))

tuple_2 = eval(input('Enter tuple two: '))

# before swapping

print('Before swapping: ')

print('tuple one: ',tuple_1)

print('tuple two: ',tuple_2)

# swap

tuple_1, tuple_2 = tuple_2, tuple_1

# After swapping

print('After swapping: ')

print('tuple one: ',tuple_1)

print('tuple two: ',tuple_2)

  • we input two tuple from user and print the values before swaping it
  • here i swap values in python way rather then other languages using a temp variable(boon of python)
  • print after swaping
Answered by syed2020ashaels
0

Answer:

Write a program to input any two tuples and interchange the tupel values.

Explanation:

#include<stdio.h>

int main(){

int a,b;

printf("Enter the values you want to exchange");

scanf("%d%d",&a,&b);

a=a+b;

b=a-b;

a=a-b;

printf("The exchanged value of a is %d and b is %d",a,b);

return 0;

}

#SPJ2

Similar questions