diff --git a/snippets/convert_to_binary.md b/snippets/convert_to_binary.md deleted file mode 100644 index 6f833de0b..000000000 --- a/snippets/convert_to_binary.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: convert_to_binary -tags: math,beginner ---- - -Returns the base 2 equivalent of a decimal number - -- Use `bin()` to convert a given decimal number into binary equivalent - -```py -def convert_to_binary(n): - return bin(n) -``` - -```py -convert_to_binary(100) # 0b1100100 -``` diff --git a/snippets/to_binary.md b/snippets/to_binary.md new file mode 100644 index 000000000..d289bd064 --- /dev/null +++ b/snippets/to_binary.md @@ -0,0 +1,17 @@ +--- +title: to_binary +tags: math,beginner +--- + +Returns the binary representation of the given number. + +- Use `bin()` to convert a given decimal number into its binary equivalent. + +```py +def to_binary(n): + return bin(n) +``` + +```py +to_binary(100) # 0b1100100 +```