Student or Learner
Why in the sentence
The book contrasts life in the city with life on a farm.
the noun ‘city’ is used with a definite article but the noun ‘farm’ is used with an indefinite article?
In this example, either article can be used for either noun.
On one hand, the speaker is probably talking about cities and farms in general. (It might be about one particular city, but it might not. Standing alone, the sentence doesn't give the context that would tell us.)
On the other hand, we often use "the" when talking about archetypes. We're using "the" in the sense of "the typical city."
Does that make sense?
I'm not a teacher. I speak American English. I've tutored writing at the University of Southern Maine and have done a good deal of copy editing and writing, occasionally for publication.