decimal to binary python with output in 4 converting code example Example: how to convert decimal to binary python a = 5 #this prints the value of "a" in binary print(bin(a))