Add convert_to_binary snippet
This commit is contained in:
17
snippets/convert_to_binary.md
Normal file
17
snippets/convert_to_binary.md
Normal file
@ -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
|
||||
```
|
||||
Reference in New Issue
Block a user