There are several reasons to switch codes in a single conversation:
A particular topic: People generally switch codes during discourse about a particular topic when specific language is necessary or preferred; alternative speech may better convey relevant concepts.
Quoting someone: People will switch codes while quoting another person.
Solidarity and gratitude: When expressing gratitude or solidarity, code-switching can occur inadvertently or with the intention of fostering a rapport.
Clarification: A speaker may engage in code-switching when listeners have difficulty comprehending specific words or concepts initially, or when the speaker does not know or remember the appropriate words in one of the languages.
Group identity: People may alter their language to express group identification. This can happen, for example, when introducing members of a particular group to others.
To soften or strengthen command: While asking someone to do something, code-switching works to mark emphasis or provide inspiration.
Lexical need: People often use technical or idiomatic speech from a foreign or non-primary language; code-switching occurs when translating such words or phrases could distort the precise meaning.
Unconscious effort: People may engage in code-switching without thinking about it. This can occur when one is frightened by a specific event or circumstances such as going on a thrilling ride at an amusement park.
To fit in: Code-switching is a useful tool for people to talk and act more like those around them.
To get something: When a person code-switches to a dialect, language, or accent of the local people in the area, he or she may get better deals, prices, or treatments when purchasing an item or service.
To say something in secret: Code-switching can be used when a person wants to relay a message to another person with the intention that no one else around them can understand if they converse in another language.