Files
30-seconds-of-code/snippets/convert_to_binary.md
2020-10-07 16:39:56 +05:00

277 B

title, tags
title tags
convert_to_binary math,beginner

Returns the base 2 equivalent of a decimal number

  • Use bin() to convert a given decimal number into binary equivalent
def convert_to_binary(n):
    return bin(n)
convert_to_binary(100) # 0b1100100