def set_bits(data, value, offset, bits=1):
 mask = (((1 << bits) - 1) << offset)
 clear = (65535 ^ mask)
 data = ((data & clear) | ((value << offset) & mask))
 return data

def set_bits ( data , value , offset , bits = 1 ) : mask = ( ( ( 1 << bits ) - 1 ) << offset ) clear = ( 65535 ^ mask ) data = ( ( data & clear ) | ( ( value << offset ) & mask ) ) return data
set specified bits in integer .