Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions python basics/swapnum.py
Original file line number Diff line number Diff line change
@@ -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)