Thursday 26 July 2018

Swap two variables without using third variable in Python

# Swap two variables without using third variable in Python

a = input(" Please Enter the First Number: ")
b = input(" Please Enter the second number: ")
 
print('First Number {0} Second Number {1} '.format(a, b))

a=float(b)+float(a);
b=float(a)-float(b);
a=float(a)-float(b);   


print('After Swap First Number {0} Second Number {1}'.format(a, b))



No comments:

Post a Comment