Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to do swapping in python without sort function

# Python3 program to
# swap two numbers
# without using
# temporary variable
x = 10
y = 5
 
# code to swap
# 'x' and 'y'
 
# x now becomes 50
x = x * y
 
# y becomes 10
y = x // y;
 
# x becomes 5
x = x // y;
 
print("After Swapping: x =",
              x, " y =", y);
 
PREVIOUS NEXT
Tagged: #swapping #python #sort #function
ADD COMMENT
Topic
Name
7+5 =