Python inclui exercícios 47
Título: dois valores variáveis são intercambiáveis.
Análise do Programa: Nenhum
Source Code:
#!/usr/bin/python # -*- coding: UTF-8 -*- def exchange(a,b): a,b = b,a return (a,b) if __name__ == '__main__': x = 10 y = 20 print 'x = %d,y = %d' % (x,y) x,y = exchange(x,y) print 'x = %d,y = %d' % (x,y)
O exemplo acima saída é:
x = 10,y = 20 x = 20,y = 10