18 lines
261 B
Markdown
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
|
|
```
|