Write Function to left rotate n by d bits


Topic: Write Function to left rotate n by d bits

Solution

def leftRotate(n, d): 
    INT_BITS = 32
    return (n << d)|(n >> (INT_BITS - d)) 
n = 16
d = 2
print("Left Rotation of",n,"by",d,"is",end=" ") 
print(leftRotate(n, d)) 



List all Python Programs