Each hole will have a number of strokes listed under 'Par'.Every time you take a swing at the ball, therefore, it counts as a stroke, whether anything good happens or not. On the other hand, if you take a practice swing and accidentally hit the ball, it doesn't count. But if he/she tries to hit the ball and whiffs, it still counts as a shot. It's likely that 99.9% of the time a golfer will make contact with the ball.
Count every purposeful attempt to strike a ball as a stroke.