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

Find Largest Element of an Array using Function in Python

# Find Largest Element of an Array using Function # python function to find maximum # in arr[] of size n def largest(arr,n): # Initi...