I have only just started studying computer science at A-Level and I have been set this task in python. I know it probably seems easy but I am very knew to this and am unsure of how to go about doing it please help.

Write a program that gets the user to type in how many bitsthey are using and will then tell them what the value of theleft-most column heading will be in two's complement e.g. ifthey type in 4 the program should output -8.

What have you tried? If you're totally unsure, try to ask as specific a question as possible. Are you stuck with input, before doing anything with it? Does input work, but you're not sure how to compute 2's complement in Python?

micseydel wrote:What have you tried? If you're totally unsure, try to ask as specific a question as possible. Are you stuck with input, before doing anything with it? Does input work, but you're not sure how to compute 2's complement in Python?

I have managed to get the input:

number = int(input("How many bits are you using?"))

I just cannot figure out how to use two's complement in my code to produce the correct output.

micseydel wrote:What have you tried? If you're totally unsure, try to ask as specific a question as possible. Are you stuck with input, before doing anything with it? Does input work, but you're not sure how to compute 2's complement in Python?

I have managed to get the input:

number = int(input("How many bits are you using?"))

I just cannot figure out how to use two's complement in my code to produce the correct output.

You don't need to. if you have N bits you can store 2**N values. In two's complement, one half of that is positive numbers, from 0 inclusive to (2**(N-1)-1). How can you express the bounds of the other half in a similar way, and just have a small formula that uses N to compute the lower bound?