Question : Python Program : To Swap Two Variables
PROGRAM |
# Python program to swap two variables x = 5 y = 10 # To take inputs from the user #x = input('Enter value of x: ') #y = input('Enter value of y: ') # create a temporary variable and swap the values temp = x x = y y = temp print('The value of x after swapping: {}'.format(x)) print('The value of y after swapping: {}'.format(y)) |
OUTPUT |
The value of x after swapping: 10 The value of y after swapping: 5 |
Thank you very much for reading carefully, if you have any other questions, you can share it with us through comments, if this information was important to you, please let us knows through comments.
Please do comment and share.
Thank You.
No comments:
Post a Comment