pastebin

Paste Search Dynamic
Recent pastes
OcttoBin
  1. def OcttoBin(octal):
  2.     i = 0
  3.     decimal = 0
  4.     while octal != 0:
  5.         digit = octal % 10
  6.         decimal += digit * pow(8, i)
  7.         octal //= 10
  8.         i += 1
  9.     binary = 0
  10.     rem = 0
  11.     i = 1
  12.  
  13.     while decimal != 0:
  14.         rem = decimal % 2
  15.         decimal //= 2
  16.         binary += rem * i
  17.         i *= 10
  18.     print(binary)
  19.  
  20.  
  21. octal = int(input())
  22. OcttoBin(octal)
Parsed in 0.004 seconds