0 votes
418 views
in Python by (98.9k points)
edited
Python Program to Swap Two Variables

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer
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))

 

Related questions

0 votes
1 answer 444 views
asked Jun 11, 2022 in Python by Doubtly (98.9k points)
0 votes
1 answer 587 views
0 votes
1 answer 413 views
asked Jun 11, 2022 in Python by Doubtly (98.9k points)
0 votes
1 answer 445 views
asked Jun 11, 2022 in Python by Doubtly (98.9k points)
0 votes
1 answer 446 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

Recent Badges

Doubtly Earned a badge
Doubtly Earned a badge
laxman Ji Earned a badge

5.7k questions

5.1k answers

108 comments

650 users

...