Merge pull request #302 from tasbihaasim/add-convert_to_binary
Add convert_to_binary snippet
This commit is contained in:
17
snippets/to_binary.md
Normal file
17
snippets/to_binary.md
Normal file
@ -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
|
||||
```
|
||||
Reference in New Issue
Block a user