Computer Science, asked by abdulimranxi, 2 months ago

write a python program to swap a two values

Answers

Answered by elangoramrajxc
1

Answer:

The value of x after swapping: 10

The value of y after swapping: 5

Explanation:

# 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

Answered by atrs7391
0

a = input('Enter First Value: ')

b = input('Enter Second Value: ')

print("Value of a before swapping: ", a)

print("Value of b before swapping: ", b)

c = a

a = b

b = c

print("Value of a after swapping: ", a)

print("Value of b after swapping: ", b)

Similar questions