Long story short: She should get tested! At the very least, buy 3 self-tests at the drugstore. If they all say “no,” she is not pregnant. If they all say “yes” or else give different answers, she should go to a doctor to find out for sure.
Like others have said, you have to be more specific by what you mean by “sex,” because it’s possible to get pregnant without completing sexual intercourse.
For instance, sperm is present in pre-come fluids as well as semen, so if a guy and girl have intercourse but the guy “pulls out” before coming to orgasm, the girl could still get pregnant.
Also, sperm doesn’t require a penis to get into the vagina – say, if a guy and girl are fooling around, and the guy touches himself and gets sperm on his fingers, then puts his fingers in the girl’s vagina, there you have the potential for pregnancy even though there was no sex.
If your friend’s vagina hasn’t come into contact with sperm in 4 months, she is not pregnant. (This isn’t as elusive as it sounds, because sperm doesn’t live outside the body for long. It’s not like you can transfer sperm through a toilet seat; or some guy jerks off, shakes your hand, you touch yourself, and get pregnant. No. So, she would indeed know if her vagina came into contact with sperm.)
Periods are an inconsistent way to judge potential pregnancy. The big thing about pregnancy is ovulation, not menstruation. Yes, the two are usually pretty connected, but ovulation is a lot less obvious than menstruation and it comes beforehand.
For instance, a girl can get pregnant before ever having had her period, because ovulation happens before your period, so if she has sex while she’s ovulating for the first time (likely she wouldn’t know it), she could get pregnant before having her first period.
Also, especially when you’re young, periods can be very inconsistent, and sometimes you won’t have one for months and months (there are many possible reasons – sudden change in activity levels or diet are the most common causes), or other times the period is just very irregular. In cases like these, girls don’t know if they’re ovulating or not and, like the girl who’s never had her period, could get pregnant.
Also, many women experience period-like bleeding during the first month or two of pregnancy – looks like a period, so you think you’re not pregnant, but in fact you are.