The process by which a behavior is learned through its consequences, either through reinforcement or punishment.