30 lines
492 B
Python
30 lines
492 B
Python
|
#!/bin/python
|
||
|
|
||
|
def toBinaryString(user_i:int):
|
||
|
squares = [2**i for i in range(32)]
|
||
|
squares.reverse()
|
||
|
|
||
|
ret = ''
|
||
|
show = False
|
||
|
|
||
|
for s in squares:
|
||
|
if user_i & s:
|
||
|
ret += '1'
|
||
|
show=True
|
||
|
else:
|
||
|
if show:
|
||
|
ret += '0'
|
||
|
return ret
|
||
|
|
||
|
|
||
|
def main():
|
||
|
"""
|
||
|
Ask the user for an input
|
||
|
"""
|
||
|
user_in = input("entrez un nombre :")
|
||
|
print(toBinaryString(int(user_in)))
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|