check the sensor by aiming at a uniform colour, eg blue sky, f/16 or f/22, low ISO, and out of focus.
Usually dust and specks in/on the lens have no effect on the picture quality. Greasy spots and various large marks on the lens elements may have a visible effect on the picture.