Returns the binary representation of the given number.
- Use
bin()
to convert a given decimal number into its binary equivalent.
代码实现
def to_binary(n):
return bin(n)
使用样例
to_binary(100) # 0b1100100
Returns the binary representation of the given number.
bin()
to convert a given decimal number into its binary equivalent.
def to_binary(n):
return bin(n)
to_binary(100) # 0b1100100