In NXP Semiconductors embedded software, register updates are often done with bit masks. Given a 32-bit unsigned register value, write a function that sets the 5th bit and returns the updated register.
Assume bit positions are 0-indexed from the least significant bit, so the 5th bit means bit index 4.
reg representing a 32-bit unsigned register value.Example 1
reg = 0160b0000 becomes 0b10000.Example 2
reg = 181818 is 0b10010, and bit 4 is already set, so the value does not change.0 <= reg <= 2^32 - 1A C macro for this operation would conceptually use reg | (1U << 4). Implement the equivalent logic in Python.