menu search
brightness_auto
more_vert
2 1

Write a program to swap two numbers using a third variable

Topic Python Programming
Type Python Program
Class 11
thumb_up_off_alt 2 like thumb_down_off_alt 0 dislike

1 Answer

more_vert
0

x = 1 

y = 2 

print(f'Before swapping x is {x} and y is {y}.')

temp = x # temp = 1 

x = y # x = 2

y = temp # y = 1 

print(f'After swapping x is {x} and y is {y}.')


Study more about Python at Python Class 10

thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike

Related questions

thumb_up_off_alt 2 like thumb_down_off_alt 0 dislike
1 answer
thumb_up_off_alt 2 like thumb_down_off_alt 0 dislike
1 answer
thumb_up_off_alt 2 like thumb_down_off_alt 0 dislike
1 answer
thumb_up_off_alt 2 like thumb_down_off_alt 0 dislike
1 answer
thumb_up_off_alt 3 like thumb_down_off_alt 0 dislike
1 answer
thumb_up_off_alt 3 like thumb_down_off_alt 0 dislike
0 answers
thumb_up_off_alt 3 like thumb_down_off_alt 0 dislike
1 answer
Welcome to Aiforkids, where you can ask questions and receive answers from other members of the community.

AI 2024 Class 10 Board Exams mein 100% laane ka plan OPEN NOW

Class 10 Complete One Shot AI Lectures at - Youtube

1.5k questions

1.4k answers

4 comments

5.0k users

...