def is_bit_set(byte, bit_position):
return (byte & (1 << bit_position)) != 0
Test
byte_value = 0b10101010
bit_position_to_check = 3
if is_bit_set(byte_value, bit_position_to_check):
print(f"Das Bit an Position {bit_position_to_check} im Byte {byte_value:b} ist gesetzt.")
else:
print(f"Das Bit an Position {bit_position_to_check} im Byte {byte_value:b} ist nicht gesetzt.")