From 28772f3b7a0caae399fb80fd8d6cbab6da9af6af Mon Sep 17 00:00:00 2001 From: 200111om <56404830+200111om@users.noreply.github.com> Date: Thu, 10 Oct 2019 21:44:16 +0530 Subject: [PATCH] A program for swapping numbers --- python basics/swapnum.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 python basics/swapnum.py diff --git a/python basics/swapnum.py b/python basics/swapnum.py new file mode 100644 index 0000000..d0c80a6 --- /dev/null +++ b/python basics/swapnum.py @@ -0,0 +1,18 @@ +"""This program swaps the numbers that are stored in the variables a and b which are provided by the user at runtime""" + +#Take two variables a and b and ask for user input +a=int(input("Enter a")) + +b=int(input("Enter b")) +#Print the current values of variables + +print("a=",a," b=",b) + +#Swap the numbers +#t is used as a temporary storage variable +t=a +a=b +b=t +#Print the updated values of variables + +print("a=",a," b=",b)