How to Swap Two Number With and Without Using Third Variable in Python
Swap Values in Two Variables
Suppose We Have Two Variable a and b. I want to exchange value of these two variable using third variable or without Using third variable
Example:
a = 10
b = 20
we want to change the value of these two variable. The 20 is store in variable a and 10 is store in variable b
a = 20
b =10
There are two method we used
Suppose We Have Two Variable a and b. I want to exchange value of these two variable using third variable or without Using third variable
Example:
a = 10
b = 20
we want to change the value of these two variable. The 20 is store in variable a and 10 is store in variable b
a = 20
b =10
There are two method we used
- with using third variable
- without using third variable
With Using Third Variable
In this method we use third variable called temporary variable called temp
Example: Code Program
With Out Using Third Variable
Example: Code Program
Post a Comment