Key Features

Experienced Teachers
Smart Classes
Regular Test
Study Material

Well qualified teachers with industrial experience.

To visualise or understand topics very easly.

We are organizing online and offline regular test.

We are providing prescribed study material.

Wednesday, October 14, 2020

Python Program : To Swap Two Variables

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