employer cover photo
employer logo
employer logo

Tata Consultancy Services

Part of Tata Group

Engaged employer

Tata Consultancy Services interview question

Write a program to swap two numbers using python? Since I mentioned before that my favorite programming language is python so the interviewer asked me to solve the coding question using python language.

Interview Answer

Anonymous

21 Nov 2024

# Swap two variables in Python a=int(input(“Enter value : “)) b=int(input(“Enter value : “)) print(“Before swapping a :”,a) print(“Before swapping b :”,b) #logic to swap using third variable temp=a a=b b=temp print(“After swapping a becomes :”,a) print(“After swapping b becomes :”,b)