Pergunta de entrevista da empresa Tata Consultancy Services

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.

Resposta da entrevista

Sigiloso

21 de nov. de 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)