I have a Nikon D40 and want to take photos at night of streets or amusement parks. any suggestions on settings or lens that I would have to use
Lens doesn't matter much. Exposures will likely be long, on the order of a second or so, even with a fast lens, so use whatever you have. A zoom can be handy if you want to do abstract stuff (see below)
I would suggest you set the camera to Manual exposure. Otherwise the camera will try to make all your images look like daytime. Start with aperture at f/4 and shutter speed between 1-3 seconds. You can up the ISO to 400 or 800 if you want a faster shutter speed. You'll have to review the shots on the LCD and adjust as needed.
Manual focus is probably a good idea as well, as autofocus is unlikely to work well in dark conditions.
You can get some amazing abstract shots of street and car lights with long hand-held exposures. Experiment with panning or zooming during the exposure. Results will be hit and miss, but you will sometimes get really amazing effects.
You can also intentionally take out of focus shots and get some nice abstract bokeh shots.
If you have a tripod you can have images with buildings nice and sharp, but have a lot of ghost-like motion blur with people, cars, or amusement park rides.
I suggest using a fixed focal lens because they have a larger aperture (let more light in). Start with the 35mm 1.8 DX lens.
Because you have a cheap body that does not have an AF motor you cannot use the cheaper AF-D lenses and have to go for the more expensive AF-S lenses. Of course you could use manual focus (AI) lenses, but the light meter on the D40 does not work with those and you have to set the exposure using trial and error. If this is ok for you then you will find many nice AI or E lenses on ebay for very little money.
Of course you have to use a tripod and cable release because of the longer exposure.
Amusement parks are a great place to shoot night shots. There are all the colors and lights and you can do wonderful things with a tripod.
This is a 3.2 second exposure at f10, ISO 100. I stopped the lens down to lengthen the exposure. Manual focus. It was a 17mm lens on a full frame body. This was a pretty easy shot to take, I only tried a few different exposures to get what I liked.
On the other hand, this shot presented more of a challenge.
This was 0.4 seconds, f10, ISO 400, 17mm on the same full frame body. The challenge here was deciding artistically what I wanted. Longer exposures had longer trails. I took probably about 30-40 shots of this ride, the pattern the lights made was different each time. It was also hard to decide which one to keep. Keeping more than 1 would be silly.
The best part of this was how we were treated by security. As they closed the place down they just ignored us. It was clear we were "professionals" and wouldn't cause mischief. We even chatted with Security on the way out.
Grab your tripod, cable release and go have fun.