Added example to convert int to binary (#20275)

pull/23513/head
Ken Nguyen 2018-10-19 16:40:32 -04:00 committed by Jonathan Grah
parent 3a0974f7e7
commit bda1775764
1 changed files with 14 additions and 0 deletions

View File

@ -74,6 +74,20 @@ print(list_str)
```
List of fruits: Apple, Banana, Pear
```
### Convert an integer to 8-bit binary
### Input
```python
num = 42
print(f'The binary of {num} is {num:08b}')
```
### Output
```
The binary of 42 is 00101010
```
### Sources
https://www.python.org/dev/peps/pep-0498/