In short: Av (Aperture mode) is good when you want to control depth of field (blurry background). Tv (Shutter Mode) is good when you want to control how sharp or blurry you moving images are.
Other than that, I second the idea of RTFM. Open the book that came with your camera
experiment with Aperture Priority to adjust depth of field - eg a sharp picture of a subject with a blurred back ground = low F number ... a sharp picture of subject and sharp background = high F number...
experiment with Shutter Priority to adjust shutter speed - eg a fast shutter speed to freeze motion like a race car..... or a slow shutter speed to create blur... like those waterfall pictures you've seen...
as the others have said it's more complicated than this so read up and experiment....
as I joked before your Nikon D40 should not have Av and Tv... those are lame canon terminologies..