Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
def binary(number):
base = 1
binary_val = 0
while(number > 0):
rem = number%2
binary_val = binary_val + rem*base
number = number/2
base = base*10
return binary_val
number = long(raw_input("Nhap so he thap phan:"))
print "Dang nhi phan la:",binary(number)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.