The shepherd thought this request odd, but, knowing there was little chance of guessing correctly, agreed.
"You've got 287 sheep," the programmer said. To the shepherd's astonishment, it was the correct number.
The shepherd told the man he'd guessed correctly and to go ahead and pick out a sheep to take home. But, as soon as the programmer picked up a small sheep and started to carry it away, the shepherd said, "Wait a minute. You have to give me a chance, too. If I can guess what you do for a living, can I have that sheep back?"
Figuring there was little chance the shepherd would guess correctly, the programmer went along, only to be shocked when the shepherd said, "You're a computer programmer, right?"
"How did you know?" asked the programmer.
The shepherd said, "Put down the dog and we'll talk about it."
I wonder if any non-programmers would know why this one's funny :) (without looking at the comments first)