Discussion on Week 2's Topic

What are loops and conditional statements in python?

What are loops and conditional statements in python?

by Md. Latif Bhuiyan Tusher -
Number of replies: 0

In order to write useful programs, we almost always need the ability to check conditions and change the behavior of the program accordingly. Conditional statements give us this ability. The simplest form is the if statement, which has the genaral form:


if BOOLEAN EXPRESSION:

    STATEMENTS

A few important things to note about if statements:


1.The colon (:) is significant and required. It separates the header of the compound statement from the body.

2.The line after the colon must be indented. It is standard in Python to use four spaces for indenting.

3.All lines indented the same amount after the colon will be executed whenever the BOOLEAN_EXPRESSION is true.