Tamilnadu Samacheer Kalvi 12th Computer Science Notes Chapter 6 Control Structures Notes

Control structure:
A program statement that causes a jump of control from one part of the program to another is called control structure or control statement.

Control Structures in Python:
There are three important control structures namely

  • Sequential
  • Alternative or Branching
  • Iterative or Looping

Sequential Statement:
A sequential statement is composed of a sequence of statements which are executed one after another. A code to print your name, address and phone number is an example of sequential statement.

Alternative or branching statements in Python:
The types of alternative or branching statements provided by Python are:

  • Simple if statement
  • if..else statement
  • if..elif statement

i) Simple if statement
Simple if is the simplest of all decision making statements. Condition should be in the form of relational or logical expression.

Syntax:
if:<condition>:
statements-block1

(ii) if..else statement
The if ..else statement provides control to check the true block as well as the false block. Following is the syntax of ‘if..else’ statement.

Syntax:
if:<condition>:
statements-block 1
else:
statements-block 2

iii) if..else statement
The if ..else statement provides control to check the true block as well as the false block. Following is the syntax of ‘if..else’ statement.

Syntax:
if:<condition>:
statements-block 1
else:
statements-block 2

Iteration or Looping constructs :

  • Iteration or loop are used in situation when the user need to execute a block of code several of times or till the condition is satisfied.
  • A loop statement allows to execute a statement or group of statements multiple times.

Looping constructs in Python:
Python provides two types of looping constructs:

  • while loop
  • for loop
    1. While loop:
    Syntax:
    while< condition > :
    statements block 1
    [else:
    statements block 2]

Samacheer Kalvi 12th Computer Science Notes

Leave a Reply

Your email address will not be published. Required fields are marked *