Swap two integer variable using temp variable | without using team variable | Python Tutorial

Publicado em: 15 Setembro 2024
no canal de: AI & Data Innovation
35
4

How to swap the values of two integer variables?
#python #programming #pythonprograms #pythonprogramming #pythontutorialsforbeginners #interview #fresherinterview

Solution:
1. Using temp variable
num1=10
num2=20
temp=num1
num1=num2
num2=temp

2. Without temp variable by arithmetic operation
num1=10
num2=20
num1=num1+num2 #num1=30
num2=num1-num2 #num2=30-20
num1=num1-num2 #num2=30-10

print("num1=" + str(num1) + "\n" + "num2=" + str(num2))


My profile : https://www.dot-net-tutorials.com/p/i...
My Linkedin Profile:   / mdafazal  


Nesta página do site você pode assistir ao vídeo on-line Swap two integer variable using temp variable | without using team variable | Python Tutorial duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário AI & Data Innovation 15 Setembro 2024, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 35 vezes e gostou 4 espectadores. Boa visualização!