Your question is Bit Manipulation: 4th LSB. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
IBM watsonx monitoring processes configuration values supplied as decimal integers. Given a non-negative decimal integer n, return its fourth least significant bit in the number's binary representation. The least significant bit is bit position 0, so the requested bit is bit position 3.
Solve the problem using bit manipulation rather than converting the number to a binary string. The result must be either 0 or 1.
Implement fourth_least_significant_bit(n), where n is a non-negative Python integer. Return an integer representing bit position 3 of n:
1 if that bit is set.0 otherwise.Leading zeroes in the binary representation do not affect the result.
def fourth_least_significant_bit(n):