The problem is small airplanes use automotive style rheostat (variable resistor) fuel senders, with the float in the tank, and these just aren't reliable enough to be trusted with something potentially life or death like fuel quantity, and they aren't particularly accurate in the first place.
Here's the thing... In a car you just drive around going past gas stations constantly until the gauge is low. Imagine you were operating a car in some remote place where the gas stations were 300 miles apart and if you run out of gas short of the next gas station, the road is full of hungry alligators equipped with Slim Jims, making your door locks useless, and you, dinner.
Well, your tank is good for 600 miles and it's half full on the gauge. Maybe good for 300 miles, maybe not. Are you willing to trust the automotive gauge now? This is what faces you as pilot any time the tanks are not full, in an airplane with 40 year old fuel senders, that maybe sits around for extended periods.
Bigger airplanes use fuel quantity measurement systems that use "Capacitance Probes", hollow tubes with a center rod, and a current is passed through and the capacitance measured by the fuel level in the tube that completes the circuit between the outer tube and the inner rod. A computer will monitor the levels from several probes arranged around the tank and they provide a very precise and reliable fuel reading.
There are capacitance probe senders available for homebuilt aircraft, but I'm not aware of any certified units that can be installed in something like a 152. If available, that would be a good solution, although I'd probably still not be willing to trust it 100%.
Best thing is to use a dipstick and be aware of your fuel consumption/time. During training and renting airplanes, people get into the habit of always going somewhere with full tanks, but later on, especially if you are flying commercially, you are going to have to fly a lot with intermediate quantities, excess fuel being unwanted ballast, so you need to get into the habit of knowing and tracking fuel quantity.
Impress your instructor by showing up with something like this and you will always know exactly how much fuel you have. If you're cheap and refuel the plane yourself you can make your own with a wood stick if you have a way to get all the useable fuel out of the tank, then add 5 gal at a time and marking your stick appropriately at each level.