In basketball, every time the offense produces a shot opportunity the player with the ball must decide whether the shot is worth taking. In this paper, I explore the question of when a team should shoot and when they should pass up the shot by considering a simple theoretical model of the shot selection process, in which the quality of shot opportunities generated by the offense is assumed to fall randomly within a uniform distribution. I derive an answer to the question "how likely must the shot be to go in before the player should take it?", and show that this "lower cutoff" for shot quality $f$ depends crucially on the number $n$ of shot opportunities remaining (say, before the shot clock expires), with larger $n$ demanding that only higher-quality shots should be taken. The function $f(n)$ is also derived in the presence of a finite turnover rate and used to predict the shooting rate of an optimal-shooting team as a function of time. This prediction is compared to observed shooting rates from the National Basketball Association (NBA), and the comparison suggests that NBA players tend to wait too long before shooting and undervalue the probability of committing a turnover.