Learn Python Programming 6 - Variables (Swapping Practical Interview Questions and Solutions 1)

Опубликовано: 02 Май 2026
на канале: TNTeach #NCERT #CBSE #Python
121
10

Python variables and swapping
print("Python in Action")
x = 5
y = 10
z = 15
print("The value of x is ", x)
print("The value of y is ", y)
print("The value of z is ", z, "\n")
x = z
y = 87
print("The value of x is ", x)
print("The value of y is ", y)
print("The value of z is ", z, "\n")

print("Python in Action Q/A")
x = input("Enter the Value of x: ")
y = input("Enter the Value of y: ")
print("The value of x is ", x)
print("The value of y is ", y)

temp = x
x = y
y = temp

print("\nAfter Swapping:")
print("The value of x is ", x)
print("The value of y is ", y)


print("Python in Action Q/A")
x = input("Enter the Value of x: ")
y = input("Enter the Value of y: ")
print("The value of x is ", x)
print("The value of y is ", y)

x,y = y,x

print("\nAfter Swapping:")
print("The value of x is ", x)
print("The value of y is ", y)