So i have been working through a book learning how to do some programming and i came across an exercise that i would like to have more clarification around.

The exercise is the following:
We are given a number N and a position P. Write a sequence of operations that prints the value of the bit on the position P in the number. (0 or 1) Example : N = 35, P = 5 -> 1 Another example N = 35, P = 5 -> 0.

Given that exercise i would like to first print out the binary representation of N convert that binary form into a string or a integer. Then perform the operation working out if the position is either a 1 or a 0.
The second thing i would like to do is perform that operation and then flip the bit. Then convert it from the binary back into the int and post up the new value as both the int and the binary form of that.

Hope this makes sense. This is all pretty new to me and i dont think i fully have the vocabulary to express exactly what i mean. But a few examples that do what i want would be very much appreciated. I really want to get a firmer picture in my head of working with binary and doing bitwise operations and comparisons.