Python swapping program

https://www.itcomputerguruji.com/2021/04/python-swapping-program.html,

Write a program in python to read 3 numbers in 3 variables and swap first two variables with the sums of first and second.

Note:- Program to read three numbers in three variables and swap first two variables with the sums of first and second ,second and third number respectively 

num1=int(input("Enter First Number : "))

num2=int(input("Enter Second Number : "))

num3=int(input("Enter Third Number : "))

print("Before Swap the value is : ",num1, num2, num3)

num1,num2,num3=(num1+num2), (num2+num3), (num3+num1)

print("After Swap the value is : ",num1, num2, num3)

Output :-

Enter First Number : 3

Enter Second Number : 4

Enter Third Number : 6


Before Swap the value is :  3 4 6

After Swap the value is :  7 10 9


Post a Comment

0 Comments