Program to swap the values of two variables.

Code:

a = 10;

b = 20;

temp=0;

print("Before swapping: ")

print("a: ",a)

print("b: ",b)

temp=b;             

b=a;

a=temp

print("After swapping: ")

print("a: ",a)

print("b: ",b)

 

Output:

Comments

Popular posts from this blog

Practical No. 3: Write a simple Python program using operators : Arithmetic ,Logical ,Bitwise Operators. ((MSBTE Pratical Question))