Advertisement
PedroPauloFO

Untitled

Jun 12th, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. # coding: utf-8
  2. # Programação 1, 2014.1 Pedro Paulo
  3. # Octal Decimal
  4.  
  5. numeros_str = raw_input()
  6.  
  7. tamanho_numero = len(numeros_str)
  8.  
  9. potencia = 0
  10. total_decimal = 0
  11. for i in range (0, tamanho_numero):
  12.  
  13.     convertido = int(numeros_str[i]) * (8**((tamanho_numero - i)-1))
  14.     numeral_da_vez = int(numeros_str[i])
  15.     potencia = ((tamanho_numero - i)-1)
  16.     print "%d * 8^%d = %d" % (numeral_da_vez, potencia, convertido)
  17.     total_decimal += convertido
  18.    
  19.  
  20. print "%s(8) = %d(10)" % (numeros_str, total_decimal)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement