Penny buys 4 pairs of socks for $2 x 4 = $<<4*2=8>>8.
In total, Penny spent $8 + $7 = $<<8+7=15>>15 on 4 pairs of socks and a hat.
Penny has $20 -$15 = $<<20-15=5>>5 left after buying 4 pairs of socks and a hat.
#### 5