Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,859 questions

51,780 answers

573 users

How to use bitwise operators as functions in Python

1 Answer

0 votes
from operator import *
 
a = 1
b = 2    
 
 
print('and_(a, b):',  and_(a, b))     
print('or_(a, b):', or_(a, b))     

print('invert(b):', invert(b))     

print('lshift(a, b):', lshift(a, b))     
print('rshift(a, b):', rshift(a, b))     

print('xor(a, b):', xor(a, b))
 
 
 
'''
run:
 
and_(a, b): 0
or_(a, b): 3
invert(b): -3
lshift(a, b): 4
rshift(a, b): 0
xor(a, b): 3

'''

 



answered May 30, 2019 by avibootz

Related questions

1 answer 147 views
1 answer 150 views
1 answer 145 views
1 answer 129 views
1 answer 117 views
...