From c91d5acdc1f712703cdd8e074fc8c39b3a5d2728 Mon Sep 17 00:00:00 2001 From: tasbihaasim Date: Wed, 7 Oct 2020 16:32:56 +0500 Subject: [PATCH 1/3] Add convert_to_binary snippet --- snippets/convert_to_binary.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 snippets/convert_to_binary.md diff --git a/snippets/convert_to_binary.md b/snippets/convert_to_binary.md new file mode 100644 index 000000000..9c6d4fc00 --- /dev/null +++ b/snippets/convert_to_binary.md @@ -0,0 +1,17 @@ +--- +title: arithmetic_progression +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 +``` \ No newline at end of file From 950f08cf72ca28d2cb82fb093bbdd9bb64188f54 Mon Sep 17 00:00:00 2001 From: tasbihaasim <54742672+tasbihaasim@users.noreply.github.com> Date: Wed, 7 Oct 2020 16:39:56 +0500 Subject: [PATCH 2/3] Update convert_to_binary.md --- snippets/convert_to_binary.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/convert_to_binary.md b/snippets/convert_to_binary.md index 9c6d4fc00..6f833de0b 100644 --- a/snippets/convert_to_binary.md +++ b/snippets/convert_to_binary.md @@ -1,11 +1,11 @@ --- -title: arithmetic_progression +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 +- Use `bin()` to convert a given decimal number into binary equivalent ```py def convert_to_binary(n): @@ -14,4 +14,4 @@ def convert_to_binary(n): ```py convert_to_binary(100) # 0b1100100 -``` \ No newline at end of file +``` From f511b9189bc5353b1842aab5de5e4f7e058b7461 Mon Sep 17 00:00:00 2001 From: Isabelle Viktoria Maciohsek Date: Wed, 7 Oct 2020 19:46:01 +0300 Subject: [PATCH 3/3] Update and rename convert_to_binary.md to to_binary.md --- snippets/convert_to_binary.md | 17 ----------------- snippets/to_binary.md | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 17 deletions(-) delete mode 100644 snippets/convert_to_binary.md create mode 100644 snippets/to_binary.md 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 +```