Conditional statements let a program choose what to do based on data. The simplest form is if: a header line with a condition and a colon, followed by an indented block. If the condition is true, the block runs; if not, Python skips it and carries on after the block. Without conditionals every program would do exactly the same thing every time, whatever its input.
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 6 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.