Saltar a contenido

Chapter 6: If Statements

If statements allow your program to make decisions based on conditions.

Example

Python
1
2
3
4
5
age = 18
if age >= 18:
    print("You are an adult.")
else:
    print("You are not an adult.")

This code checks if age is 18 or more and prints the appropriate message.