This commit is contained in:
Debucquoy
2023-09-20 15:18:20 +02:00
parent 00d0cdfaf3
commit 4fd7542f03
228 changed files with 351 additions and 12 deletions

View File

@ -0,0 +1,29 @@
#!/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()