Index Ai Academy
Phase 0 · Tools · Python core

Decisions with if/else

Compare values and choose what happens next.

About 20 minutes · Free lesson

Start this lesson

Why it matters

Programs earn their keep by reacting to data: route a lead to sales or to a nurture sequence, flag a campaign that's overspending, retry an API call that failed, decide whether a model's answer passed a check. Every evaluation you'll run on an AI system later comes down to conditions like the ones in this lesson.

What you'll be able to do

  • Compare values with ==, !=, <, >, <= and >=
  • Run different code depending on a condition with if, elif and else
  • Combine conditions with and, or and not
  • Avoid the classic mistakes: = vs ==, indentation, and comparing floats

Before this lesson

Next in this phase: Lists