Files
30-seconds-of-code/snippets/to_binary.md
2020-10-07 19:46:01 +03:00

18 lines
261 B
Markdown

---
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
```