Skip to content

Instantly share code, notes, and snippets.

@echiesse
Last active October 18, 2017 18:41
Show Gist options
  • Save echiesse/52bfc9663f92c6825d9d84ad2573a7cf to your computer and use it in GitHub Desktop.
Save echiesse/52bfc9663f92c6825d9d84ad2573a7cf to your computer and use it in GitHub Desktop.
Exemplo de conversão de decimal para binário
num = int(input("Escolha um número decimal para transformar em binario: "))
result = []
while num >= 1:
bit = num % 2
result.append(bit)
num = int(num/2)
# Imprimir em ordem inversa
print("".join(map(str, result))[::-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment