San Francisco is 46.7 square miles, and all the top sights are accessible by its excellent public transportation system, which has both light-rail (Muni) and trains (BART) in addition to the famous cable cars. It's also a city that welcomes pedestrians, and most tourist neighborhoods are safe and easy to reach on foot. Be aware, however, that some parts of the city have very steep hills, making what seems like a quick walk on the map into a strenuous hike.
Along with the multiple tourist bike rentals available from kiosks along Fisherman's Wharf, San Francisco supports a city-wide bike-share program called Bay Area Bikeshare. 24-hour or 3-day short-term memberships are available at any of their 70 stations, and bikes can be rented at returned at any point along your route. Two useful resources are BikeMapper, an online app that lets you plot your ride on a map, and San Francisco Bicycle Coalition, which has all the info you need about the rules of the road as well as a list of local cycling events.
San Francisco's subway goes by the acronym BART, for Bay Area Rapid Transport. The tracks are not extensive, but it's a convenient way to get to the East Bay and to and from either of the major airports of Oakland and SFO. Trains run at regular intervals on weekdays from around 4 a.m. to 8 p.m., but late evenings and weekends there can be up to a 20-minute wait. Tickets for travel within the city are a flat fare of $1.75; to get across the bay to San Francisco International Airport will cost upwards of $8.
Supplementing BART is Muni, a light-rail system that encompasses buses, streetcars, F-line trolleys, and cable cars. Every visitor to San Francisco should take at least one ride on the storied cable cars, which run up and down the hills from Union Square to Fisherman's Wharf, and offer fantastic Bay views. Standard fare for the bus, streetcars, and trolleys is $2, while the cable car will run you $6. Muni provides a one-day, three-day, and seven-day Muni Passport, which can be purchased at the visitor information center in Hallidie Plaza, or at any of the cable car kiosks along the Wharf.
Taxis can be hailed on the street but can be difficult to find, especially when it's raining or at high-volume times like Friday nights, when you're most likely to find them at taxi stands near the major hotels. For airport travel, it's best to plan ahead and reserve a taxi or shuttle online or by phone. Uber services the entire Metro area, and is accessible via their app or online, and while rental cars are of course available they're best for trips outside of the city to Napa or Marin. With many one-way streets, steep hills, and very little parking, San Francisco is a very difficult place to drive for those unaccustomed to its quirks.