From 7f57bc5f0d06703e3cc30cf3884d5fac1ed28058 Mon Sep 17 00:00:00 2001 From: Tyni Egoda Gedarage <83944194+TyniEgodagedarage@users.noreply.github.com> Date: Fri, 22 Oct 2021 12:17:20 +0530 Subject: [PATCH] Swap two integers --- Python/swap.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Python/swap.py diff --git a/Python/swap.py b/Python/swap.py new file mode 100644 index 00000000..f14452b9 --- /dev/null +++ b/Python/swap.py @@ -0,0 +1,13 @@ +num1 = input('Enter First Number: ') +num2 = input('Enter Second Number: ') + +print("Value of num1 before swapping: ", num1) +print("Value of num2 before swapping: ", num2) + +# swapping two numbers using temporary variable +temp = num1 +num1 = num2 +num2 = temp + +print("Value of num1 after swapping: ", num1) +print("Value of num2 after swapping: ", num2)