Modify a bit at a given position | Returns modified n . ; Driver code
def modifyBit ( n , p , b ) : NEW_LINE INDENT mask = 1 << p NEW_LINE return ( n & ~ mask ) | ( ( b << p ) & mask ) NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT print ( modifyBit ( 6 , 2 , 0 ) ) NEW_LINE print ( modifyBit ( 6 , 5 , 1 ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT