CHAPTER 17 •
PYTHON
Python If Statement
Learn how to execute code when a condition is true.
01 What is this?
Learn how to execute code when a condition is true.
02 Syntax
Python Syntax
if condition:
statement
03 Example
Python Example
age = 20
if age >= 18:
print('Adult')
04 Important Points
Python uses indentation after the colon.
05 Common Mistakes
Do not forget the colon after the condition.
06 Real World Use
If statements are used for validation and decision-making.
07 Practice This Topic
Now try the example yourself in the AIFA Python Editor.
- Read the example carefully.
- Change the values.
- Run the code.
- Observe the output.
- Try creating your own example.