How do you write binary?

Asked 1 years ago, Updated 1 years ago, 79 views

I know that hexadecimal numbers have 0x in front of it, and octal numbers have 0 in front of it So what do we do to express it's binary

python syntax binary literals

2022-09-21 15:47

1 Answers

>>> 0b101111
47
>>> bin(173)
'0b10101101'
>>> print int('01010101111',2)
687
>>> print int('11111111',2)
255

This method can only be used for strings It cannot be used in the form of int (0101, 2).


2022-09-21 15:47

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.