Two variables s and m, write a Python program to swap their values. Let’s see and parform different methods in Python to do this task.
| m = input('Enter value of m : ') |
| s = input('Enter value of s : ') |
| |
| temp = m |
| m = s |
| s = temp |
| |
| print('The value of m after swapping :: {}'.format(m)) |
| print('The value of s after swapping :: {}'.format(s)) |
OUTPUT
| Enter value of m : MOM |
| Enter value of s : DAD |
| The value of m after swapping :: DAD |
| The value of s after swapping :: MOM |
In this program, we use the temp variable to hold the value of m temporarily. We then put the value of s in m and later temp in s. In this way, the values get exchanged.
0 Comments
Please Do Not Comments Any Span Or Span link..