The answer to this question is operant conditioning in psychology.
Operant conditioning is a type of learning where the behavior of a person or individual is being shaped or molded by consequences. In this type of learning, the behavior of the person is controlled by either thru a reward or punishment. Operant conditioning is also known as instrumental learning.