python coding
Friday 20 November 2015
Decimal to Binary conversion in Python
#define function
def divideby2(a,s):
if a>0:
s.append(a%2)
a=a/2
divideby2(a,s)
s=[]
#call function
divideby2(17,s)
while s!=[]:
print s.pop()
Home
Subscribe to:
Posts (Atom)