The IF Statement

tags: #python/documentation/python_conditionals

What is a One-Way IF Statement?

A one-way if statement, also known as a simple or basic if statement, is a fundamental construct in programming that allows you to conditionally execute a block of code based on a specified condition. If the condition is:

Basic Syntax

To create an IF conditional statement:

if condition:
    # Code to be executed if the condition is True

The condition followed by the IF keyword is a boolean expression. Should the expression evaluate to True, the associated block of code is executed.

Syntax

We need to end the IF statement with a : followed by indentation for the body of the conditional statement. The basic structure of an IF statement consists of:

  1. Header line that ends with a colon character.
  2. Indented block of code to be executed if condition is True.
Powered by Forestry.md