Added example to convert int to binary (#20275)
parent
3a0974f7e7
commit
bda1775764
|
@ -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/
|
||||
|
|
Loading…
Reference in New Issue