- irshift() is a python function predefined in operator module.
-It work on the numeric value, it shift the binary bit to the right side.
Syntax-
operator.irshift(number,leftshift)
Example-
operator.irshift(4,1) will return 2
How?
Binary of 4 is 000000100 then,
(3,1) means right shift one time then above binary number become - 000000010,
00000010 is 2 in decimal.
program-
import operator
print("Enter number")
n=int(input())
print('Right shift of this number 1 time is ',operator.irshift(n,1))
print('Right shift of this number 2 time is ',operator.irshift(n,2))
print('Right shift of this number 3 time is ',operator.irshift(n,3))
print('Right shift of this number 4 time is ',operator.irshift(n,4))
print('Right shift of this number 5 time is ',operator.irshift(n,5))
print('Right shift of this number 6 time is ',operator.irshift(n,6))
Enter number
192
Right shift of this number 1 time is 96
Right shift of this number 2 time is 48
Right shift of this number 3 time is 24
Right shift of this number 4 time is 12
Right shift of this number 5 time is 6
Right shift of this number 6 time is 3
Enter number
256
Right shift of this number 1 time is 128
Right shift of this number 2 time is 64
Right shift of this number 3 time is 32
Right shift of this number 4 time is 16
Right shift of this number 5 time is 8
Right shift of this number 6 time is 4