Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

binary operation python

x << y
"left shifted x by y places"
x >> y
"right shift x by y places"
x & y
"bitwise and"
x | y
"bitwise or".
~ x
"Complement of x"
x ^ y
"bitwise exclusive or"
Comment

binary representation python

>>> bin(88)
'0b1011000'
>>> int('0b1011000', 2)
88
>>> 

>>> a=int('01100000', 2)
>>> b=int('00100110', 2)
>>> bin(a & b)
'0b100000'
>>> bin(a | b)
'0b1100110'
>>> bin(a ^ b)
'0b1000110'
Comment

binary python

def bin(n):
    s=""
    while n!=0:
        if n%2==1:
            s+="1"
            n//=2
        elif n%2==0:
            s+='0'
            n//=2
    return s
Comment

python binary

num = 10
bin(num)
Comment

PREVIOUS NEXT
Code Example
Python :: python find string count in str 
Python :: python convert list of lists to array 
Python :: how to append string to another string in python 
Python :: python list of list to list of string 
Python :: pip matplotlib 
Python :: python how to add to a list 
Python :: Check status code urllib 
Python :: how to count specific element in a list python 
Python :: browser = webdriver.firefox() error 
Python :: pandas dataframe display cell size 
Python :: python for continue 
Python :: replace nan using fillna 
Python :: get binary string python 
Python :: flask session auto logout in 5 mins 
Python :: python os.walk recursive 
Python :: logarithms python 
Python :: absolute url 
Python :: spyder new instance 
Python :: swapping in python 
Python :: python rotate list 
Python :: skimage local threshold 
Python :: random chars generator python 
Python :: getting input in python 
Python :: create app in a django project 
Python :: python multiply 2 variables 
Python :: pass arguments with apply 
Python :: python sort algorithm 
Python :: merge two netcdf files using xarray 
Python :: flat numpy array 
Python :: scikit tsne 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =