In general terms, "sex" refers to the biological differences between males and females, such as the *******ia and genetic differences.
"Gender" is more difficult to define, but it can refer to the role of a male or female in society, known as a gender role, or an individual's concept of themselves, or gender identity.
Sometimes, a person's genetically assigned sex does not line up with their gender identity. These individuals might refer to themselves as transgender, non-binary, or gender-nonconforming.
https://www.medicalnewstoday.com/articles/232363.php