"Do you have a pencil?"
Translation:У тебя есть карандаш?
As far as I can tell, this is because, in this question, the existence of a pencil is being questioned. If you know there are pencils and want to know if someone specific has one, then that might allow you to cut it, or colloquial speech allows for this 'laziness'. Duo tries to teach you 'proper' Russian, so the complete sentence is given.
If you know natives don't use the full version, you are free to do the same in speech, but in writing (or at least here on Duolingo), I'd suggest sticking to the formal/full versions of the sentence.
I've been getting really mixed signals from Duo about using/not using есть in sentences like this. There is not context provided, hence both possibilities you set out are "correct", and у тебя карандаш ought to be accepted.
I'm reporting it as an acceptable answer, so I suppose we'll see what happens.
So it is У тебя есть карандаш because in this kind of sentence the pencil is nominative, but У тебя нет карандаша because the negative always uses genitive...do I have that right?