Your first step in answering this question is to reflect on your personal code of ethics and morality to see how it has developed and from what sources you have learned and shaped this code. Let's review some possible sources.
First, many people attain at least the beginnings of their personal code as children under the guidance of their parents and other trusted adults, including other relatives, teachers, and mentors. Most often, our parents are the first people to teach us right from wrong, and these messages are strengthened when we go to school and learn how to behave honestly, responsibly, fairly, and even lovingly toward other people.
Your own experiences have likely helped you further develop your code as you see how people act toward each other and notice how their behavior affects themselves and other people. You have probably also experienced the consequences of your own behavior, good or bad, and this also influences your code of ethics.
Religious people often adopt, even embrace, the code of ethics provided by their faith communities. A person's culture and the laws of their country, state, and locality also help shape a code of ethics.
We've all experienced times when we are pressured to break our code of ethics. A friend may want you to do something you know is wrong and will not end well. You may be tempted to cheat on a test or an assignment because you haven't prepared enough to do it well on your own. You may even have the temptation to break your code of ethics to get ahead in a job if the boss asks you to compromise your personal “beliefs” for the sake of the company or if a promotion is on the line. If your code of ethics is strong and well-defined, your conscience will immediately send up a red flag to warn you that something isn't right and that you might make a wrong choice if you aren't careful. You will have to review your own experiences to see how things turned out for you under pressure, and if your moral code was strong enough to hold up, or if you compromised.