(With or without using User defined Function)
def swap(x,y):
x,y=y,x
print("swaping x=",x,"and y is ",y)
a=int(input("Enter number 1=>"))
b=int(input("Enter number 2=>"))
ch=int(input("press 1 for without UDF and press 2 for with UDF"))
if ch==1:
print("Swaping without UDF")
a,b=b,a
print("swaping a=",a,"and b is ",b)
elif ch==2:
print("Swaping with UDF")
swap(a,b)
else:
print("Invalid choice")
Leave a Reply