Scroll Down to See All▾
absaiterallanextanyasciiboolbreakpointbytearraybytescallablechrclassmethodcompilecomplexdelattrdictdivmodenumerateevalexecfilterfloatformatfrozensetgetattrglobalshasattrhashhelphexidinputintisinstanceissubclassiterlenlistlocalsmapmaxmemoryviewminnextobjectoctopenordpowprintpropertyrangereprreversedroundsetsetattrslicesortedstaticmethodstrsumsupertupletypevarszip__import__clear_(dict)clear_(list)clear_(set)copy_(dict)copy_(list)copy_(set)fromkeysgetitemskeyspop_(dict)pop_(list)pop_(set)popitemsetdefaultupdatevaluescount_(tuple)count_(list)count_(str)index_(tuple)index_(list)index_(str)adddifferencedifference_updatediscardintersectionintersection_updateisdisjointissubsetissupersetremove_(set)remove_(list)symmetric_differencesymmetric_difference_updateunionupdateclosefilenoflushisattyreadreadablereadlinereadlinesseekseekabletelltruncatewritablewritewritelinesappendextendinsertreversesortcapitalizecasefoldcenterencodeendswithexpandtabsfindformatisalnumisalphaisasciiisdecimalisdigitisidentifierislowerisnumericisprintableisspaceistitleisupperjoinljustlowerlstripmaketranspartitionreplacerfindrindexrjustrpartitionrsplitrstripsplitsplitlinesstartswithstripswapcasetitletranslateupperdirzfillFunction Details: bin
Description
Returns the binary representation of an integer.
Extended Description
The bin() function converts an integer number to a binary string prefixed with '0b'. This function provides a simple way to see the binary representation of a number. If the argument is not an integer, it must define an __index__() method that returns an integer.
Exceptions
- TypeError: If the argument does not have an __index__() method that returns an integer
Read More about bin from Python Documentation
Function Signature
bin(x: int) -> str
Module: builtins
Parameters
This function takes one parameter: x (an integer). If x is not an integer, it should be an object that implements __index__() method returning an integer.
Parameter List
- x: int
Return
Returns a string starting with '0b', which is the binary representation of the input integer.
Return Type
str
Output
Explanation
This example shows how bin() works with positive, negative, and zero integers.