Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
binary
def reverse(st): rst = '' i=len(st) -1 while(i!=-1): rst = rst + st[i] i = i - 1 return rst num = raw_input("enter any positive number: ") try: if int(num) == 0: print "0" if int(num) < 0 : print "enter positive number" else: # print "valid" r = '' num = int(num) while True: if num == 0: break m = num % 2 # print m num = num / 2 # print num r = r + str(m) print reverse(r) except Exception as ex: print ex print "Enter number"
run
|
edit
|
history
|
help
0
gameboy
thnii957
PythonTuple
Manual
working with strings
python power
coupon
WoW
gameboy
Dictionary comprehension - convert to lowercase