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()
No comments:
Post a Comment
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment