Most of what follows applies to men as well as women, so don’t stop reading here just because you are a man. You may learn something.
Avoiding danger doesn’t mean you have to stay at home with the doors locked. Even that is no guarantee of safety; home invasions are far from uncommon.
The most important rule is that you don't go out and buy a gun, a knife, pepper spray, or 20 karate lessons and think that this immunises you against threats to your safety. Physically fighting, whether with a weapon or your hands is a last resort, and when you reach that point you have to be competent with your method of fighting.
The following tips can help you to avoid becoming a victim in the first place.
Be aware of your surroundings and if they don't look good, or don't feel right, go with your instinct and get out of there.
Be aware of people around you its not hard to train yourself to be aware of people around you, and especially behind you. How many, how close, are they getting closer? As with surroundings, if people near you don't feel right, move away from them, seek out areas with more people around.
Avoid infrequently travelled areas such as stair wells. Walking up and down stairs may be better for you, but taking the elevator may well be safer. If someone you have a bad feeling about gets into the elevator, leave.
Vary your routine. If there are trips you make frequently, especially on foot, if there are alternate routes, take the alternates from time to time.
Limit your sympathetic reactions. Going and getting help may be of more use in a genuine emergency than stopping to see what you can do (which is usually very little).
Think about your clothing, and what you carry. If the worst happens, are you dressed in a way that will help or hinder trying to get away, or (worst case) fight back? A tight skirt and heels may look good, but how will you deal with them in an emergency? Kicking off the heels and running in bare feet may work, but invites injuring your feet. You can pull up a skirt and run, but it takes time. A bag without a strap to carry on your shoulder ties up a hand; are you willing to drop it and its contents and run?
Don't assume home is safe. Your home may feel like your castle, but short of adding a drawbridge and a moat if someone wants entry, they will probably gain it. Don't let people you don't know and don't expect enter. Don't assume that a chain on the door will stop a determined criminal. Home invasion occurs too frequently to discount it ever happening to you. Think of alternate ways to leave if you have to. Just because you are at home, don't lock up all of your self-defense equipment. This takes some thought if you have children around. Leaving things like pepper spray or a gun around where children might be able to reach it is not a good idea. The safest place is on your person. If that doesn't work for you, invest in one of the many varieties of "quick-open" boxes available and use it. When the doorbell rings, and you are not expecting anyone, consider opening that box and taking your self-defense equipment to the door with you.
Dress conservatively. This one will get me into trouble with the feminists, and I have some sympathy for their attitude that a woman should be able to dress as she likes, where she likes, but the reality is that dressing "provocatively" among strangers is asking for trouble. Especially if alone. If on the way to somewhere where such dress is appropriate, consider either changing when you get there, or wear something conservative over it. No need to wear a burqa, but no need to invite unwanted attention either.
Run. If you are physically fit and able, running away may be an option, but have an idea where you are running to. Even if your attacker has a gun, the odds are on your side. Is he going to want to draw attention by shooting? Even police, who do lots of training hit their real-world targets with only about 5% (one in twenty) of the rounds they fire. The odds of a single round doing fatal damage are fairly small even if you are hit. Of course, not every person is fit enough for this to be a real option, particularly if the attacker is younger and fitter.
Try anything. If you end up in a car, jump out if the car moves slow enough or stops in an area with people around. If in a trunk, most modern cars are designed to have interior releases to make opening from the inside easy. If you have to, try to kick out a tail light and wave your arm or leg out of the hole to attract attention.
Give them what they want? A favorite suggested tactic of liberals and pacifists. It may be worth considering, but really it depends on what they want. If its just your money, hand it over, if its your car keys, maybe. If its your purse which contains your self-defence equipment, no (this is actually a good reason to not carry your self-defense equipment in your purse). If its you, it's your decision, and hard for me (as a man) to advise on, but my first instinct is "no way!".
Fight. Even if you have no weapon, and no training in martial arts there are some things you can do to make life very uncomfortable for an attacker. Kick, knee, fist or grab the groin of a man. Get it right and he will lose all interest in you for several minutes. Scratch or use any available object to go for the eyes. Slam the base of your palm upwards on the nose. This really hurts, and will probably start a very severe nose bleed.
If you have a weapon and can deploy it, now is the time. Once you get to the point of fighing you do whatever it takes to stop the attack. This includes things which may be fatal to the attacker. Your object isn't necessarily to kill, but if that happens as a side effect of stopping the attack, that is just too bad.
For any weapon to be effective, you need to have received at least some training in its use, and beyond that, you need to have practiced. You also need to use it without hesitation. Hesitate and you risk having it taken away and used against you.
Never give up. Once you have begun to fight back, never, ever, give up. There is a chance that one of you is going to leave the scene on a stretcher, or in a body bag. It is not going to be you. No matter if you are hurt, you don't stop fighting.
The following is a non-exhaustive list of weapons to consider, ordered in ascending order of effectiveness:
If you think a gun may be what you need, there are a couple of really good books on this subject written by women, for women, available on Amazon.