Simple example on bit representation and entropy I have read that we should think of entropy as expected bits of required to store the information provided about a variable.
For example:
If outcome of a variable is A: 0.5 and B: 0.5, then
we can store this information as:
[0] <- A # Store 0 for A
[1] <- B # Store 1 for B

In each case 1 bit is required, so entropy is:
entropy = prob of A * 1 + prob of B * 1 = 1

If outcome of a variable is A: 1.0 and B: 0.0, then
[] <- We know it is A not matter what

We don't store any bits at all, and entropy is 0.
I am more or less OK with the above examples, but what about
If outcome of a variable is A: 0.9 and B: 0.1?
If I store both variables as in the example above:
[0] <- A # Store 0 for A
[1] <- B # Store 1 for B

Then 1 bit is taken no matter what and I end up with entropy = 1, which is not right. 
If I try not to store variable A at all, 
[] <- A # Store 0 for A
[1] <- B # Store 1 for B

I get:
entropy = prob of A * 0.0 + prob of B * 1 = 0.1

Which is not right.
The correct answer is:
In [20]: from scipy.stats import entropy

In [21]: entropy([0.9, 0.1], base=2)
Out[21]: 0.46899559358928117

How should I store bits to represent out comes in my last example? 
 A: 
I have read that we should think of entropy as expected bits of required to store the information provided about a variable.

Perhaps you might modify that a bit (pun intended!). Intuitively, entropy is the expected average per-bit number of bits required to store the information, for a long enough sequence of known length. That is, if you have a long enough sequence of length $n$ with entropy $H$, then you will be able to encode it in about $nH$ bits (and not significantly less), so each bit requires, on average, about $H$ bits.

If outcome of a variable is A: 0.9 and B: 0.1?

In this case, a combinatorical argument shows that a long enough sequence of length $n$ generated with these probabilities (or a long enough sequence having these empirical probabilities) is one of about $2^{n H(0.9)}$ such sequences, and so about $n H(0.9)$ bits, per bit, is a necessary and sufficient encoding length.
A: From a practical point of view, arithmetic coding and ANS coding are two alternative approaches, each of which enable efficient encoding and decoding of sequences of data using an expected number of bits essentially equal to the theoretical bound given by the entropy. 
If you are only trying to encode a single Bernoulli random variable, then clearly you cannot represent it using fewer than 1 bit. As the other answer explains in more detail, the entropy becomes relevant when you are encoding not just one variable but a whole sequence of them. In general, the expected number of bits needed per variable cannot quite achieve the entropy bound, because the output can only use a whole number of bits (or in practice, usually a whole number of bytes or system  words), but as the sequence becomes longer the difference becomes negligible.
