Hamburg has a very good public transportation with busses, underground and ferries. This is a link to the homepage of the transportation company where you can look for the connections and more detailed prices:
For underground you have to buy tickets before departure, bus drivers, however, sell tickets, too.
If you do more than two regular drives (2, 60€) a day ticket is cheaper (5, 10 €, starting at 9:00 am, before that 6, 00 €). Also you might think about 3-day (15, 00 €) or weekly tickets (14, 10 €).
Travelling with a goup is a good option: you can buy day tickets for up to five people (8, 60 €, weekdays not between 6-9:00 am, weekend whole days). You can use them between 9:00 a.m. to 6:00 a.m. next day - so after partying no need for a new ticket).
The prices comprise the normal touristic drives within the city. Prices mentioned here are from April 2008
By the way the prettiest underground is the U3 passing the harbor with a great view. As for busses I can recommend the line 112 that connects many tourist places. Last stop is Oevelgoenne with its museum harbor and the Elbe beach. Very nice to stop by;-)
You might also like: