Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def dec_bin(n):
- list = []
- while n > 0:
- list.append(n%2)
- n = n//2
- list.reverse()
- binary = ""
- for bit in list:
- binary += str(bit)
- return binary
- n = int(input("enter your decimal number: "))
- binary = dec_bin(n)
- print(binary)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement