First thing first, although it is already mentioned, weather forecast is covered in the briefings. If the atmosphere favors thunderstorm formation, there are signs to look out for.
Now, thunderstorm clouds don't form out of nothing - meaning like, if you got "CAVOK", unless you do your takeoff 4 hours later, chances of you encountering a thunderstorm is very slim. Pre-thunderstorm clouds are usually observable 1~2 hours before the you see rain and lightning. Many people do not realize this simply because they seldom look up the sky. Signs will include low altitude cloud covers, fast changing cloud shapes etc. You will learn in your ground school how to name and identify clouds.
Thunderstorms that form quickly also dissipate quickly. In tropical areas, e.g. Singapore, it is pretty common to have a sunny morning followed by rainy afternoon. However, the area of the thunderstorm is quite small. They are not like massive systems which stretch across states. You should be able to outrun the storm or wait for it to move away without running out of fuel. Often, there will be holes around 10~20 miles wide between storms.
One thing to watch out for is small-area storms with intensity. One of the AOPA lectures mentioned this as the "weather gradient": unlike massive weather systems, where the change from light chop to moderate to heavy turbulence is a long distance, you get from smooth air to turbulence air in a very short time when you encounter these type of clouds. The bad thing is things go bad very quickly. The good thing is safety is often not far away. Always know your heading, and practice making a 180 turn with instruments alone.
If you need to get down, be sure to know where are your alternate airports all the time. It goes without saying the same applies to other emergencies as well. If you have a rough engine or you start feeling dizzy, you better be turning your plane towards the runway instead of scanning your aerial chart nervously looking for the airport symbol.
Lastly, learn how to obtain weather updates while en-route. Your Cessna 172 likely would not have a weather radar, but there are other ways to keep yourself updated - satellite links, radios, etc. If you tune yourself to the local flight-following frequency, you can hear pilot reports from planes ahead of you (you can just listen and not use flight-following). Or you can try the AWOS station 30 miles away. If you're using a satellite link for a radar image, be aware that the images are usually 5~15 minutes old. Never try to navigate through a storm with satellite images. The storm will have moved by the time you think you're in the clear hole. However you can use it to spot rain clouds 80 or 100 miles away.
Side story: there is a story circulating the local flying club from around the 80s or 90s. At that time, GA planes share the only airport, which has only one runway, with commercial airliners. To keep things speeded up, GA planes which depart in the afternoon are not allowed to come back until 2~3 hours later (unless it's an emergency), since sequencing a C172 between two B747s is a nightmare when the airport is operating near full capacity.
So, one GA pilot departed on an afternoon, and he really didn't like weather on his climb out - clouds were nearly overcast behind a mountain, and 2000 ~ 3000 feet was nearly IMC. He radioed in asking if he can land. The controller asked, "How is the weather out there?" The pilot was so nervous and so worried about the weather, he keyed his radio and transmitted:
"The weather is bad bad bad bad bad bad bad bad bad!"