Write a program to input any two tuples and interchange the tupel values.
Answers
Answered by
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
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
English,
5 months ago
Computer Science,
10 months ago