1st pu notes

1st PUC Computer Science Chapter 6 Flow of Control Notes

Venkatesh A August 15, 2026 8 min read
1st PUC Computer Science Chapter 6 Flow of Control Notes | VerakWorld
VERAKWORLD.COM

Complete Short Notes & Exam Preparation Guide

1st PUC / Class XI Computer Science

Based on the NCERT textbook

Chapter Overview

Flow of control means the order in which statements in a program are executed. This chapter explains selection, indentation, repetition, for and while loops, range(), break, continue and nested loops.

Exam Focus: if, if..else, if..elif, indentation, for loop, while loop, range(), infinite loop, break, continue and nested loops.

Table of Contents

1. Introduction to Flow of Control

Definition: Flow of control is the order in which statements in a program are executed.

In a sequential program, Python executes statements one after another from the beginning to the end. Control structures are used when a program needs decision making or repetition.

Main Control Structures

  • Selection
  • Repetition

Sequential Program Example

num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
diff = num1 - num2
print("The difference of", num1, "and", num2, "is", diff)

2. Selection

Selection: Decision making in which one of two or more possible options is selected according to a condition.

2.1 if Statement

if condition:
    statement(s)

If the condition is true, the indented statement block is executed.

age = int(input("Enter your age "))

if age >= 18:
    print("Eligible to vote")

2.2 if..else Statement

if condition:
    statement(s)
else:
    statement(s)
age = int(input("Enter your age: "))

if age >= 18:
    print("Eligible to vote")
else:
    print("Not eligible to vote")

Positive Difference

if num1 > num2:
    diff = num1 - num2
else:
    diff = num2 - num1

Decision-Making Flowchart

Start verakworld.com Input num1, num2 verakworld.com Is num1 > num2? verakworld.com Yes diff = num1-num2 verakworld.com No diff = num2-num1 verakworld.com Print diff verakworld.com Stop verakworld.com

Flow chart depicting decision making

2.3 if..elif..else

if condition:
    statement(s)
elif condition:
    statement(s)
elif condition:
    statement(s)
else:
    statement(s)

Positive, Negative or Zero

number = int(input("Enter a number: "))

if number > 0:
    print("Number is positive")
elif number < 0:
    print("Number is negative")
else:
    print("Number is zero")

Nested if

A selection structure placed inside another selection structure is called a nested if. The calculator example in the chapter uses nested conditions.

Simple Calculator Logic

if op == "+":
    result = val1 + val2
elif op == "-":
    if val1 > val2:
        result = val1 - val2
    else:
        result = val2 - val1
elif op == "*":
    result = val1 * val2
elif op == "/":
    if val2 == 0:
        print("Error! Division by zero is not allowed.")
    else:
        result = val1 / val2
else:
    print("Wrong input, program terminated")

3. Indentation

Definition: Indentation is the leading whitespace at the beginning of a statement. Python uses it to define blocks and nested blocks.
  • Statements at the same indentation level belong to the same block.
  • Python checks indentation strictly.
  • Incorrect indentation may produce syntax errors.
  • The body of an if or loop must be indented.
  • Nested blocks require further indentation.
if num1 > num2:
    print("first number is larger")
    print("Bye")
else:
    print("second number is larger")
    print("Bye Bye")

4. Repetition

Repetition / Iteration: Repeated execution of a set of statements.

Loops avoid writing a large number of repeated statements. The chapter describes two looping constructs: for and while.

Important: A loop should eventually reach an exit condition. Otherwise it can become an infinite loop.

4.1 The for Loop

The for loop iterates over a range of values or a sequence. It executes its body for each item and then transfers control to the statement following the loop.

for <control-variable> in <sequence/items in range>:
    <statements inside body of the loop>
Start verakworld.com Initialisation Statement verakworld.com Test Expression verakworld.com True Body of ‘For’ Loop verakworld.com False Exit for Loop verakworld.com Statement following the loop verakworld.com Stop verakworld.com

Flow chart of for loop

Example

for letter in 'PYTHON':
    print(letter)

Even Number Example

numbers = [1,2,3,4,5,6,7,8,9,10]

for num in numbers:
    if (num % 2) == 0:
        print(num, 'is an even Number')

4.1.1 range() Function

Syntax: range([start], stop[, step])
  • Generates a sequence of integers.
  • The stop value is excluded.
  • start is optional.
  • step is optional.
  • Default start is 0.
  • Default step is 1.
  • step may be positive or negative, but not zero.
list(range(10))
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

list(range(2, 10))
# [2, 3, 4, 5, 6, 7, 8, 9]

list(range(0, 30, 5))
# [0, 5, 10, 15, 20, 25]

list(range(0, -9, -1))
# [0, -1, -2, -3, -4, -5, -6, -7, -8]

4.2 The while Loop

Definition: The while statement repeatedly executes its body as long as its control condition remains true.
while test_condition:
    body of while
  • The condition is checked before the body.
  • If initially false, the body is not executed.
  • The condition is checked again after every iteration.
  • The condition should eventually become false.
  • Otherwise an infinite loop may occur.

Flowchart of while Loop

Start verakworld.com Initialisation Statement verakworld.com Test Expression verakworld.com True Body of while Loop verakworld.com False Statements following the while loop verakworld.com Stop verakworld.com

Flow chart of while Loop

Example

count = 1

while count <= 5:
    print(count)
    count += 1

Infinite Loop

If the loop condition never becomes false, the loop may continue indefinitely. The chapter identifies this as a logical error.

5. Break and Continue Statements

5.1 break Statement

break: Terminates the current loop and transfers control to the statement following the loop.
for num in range(10):
    num = num + 1

    if num == 8:
        break

    print('Num has value ' + str(num))

5.2 continue Statement

continue: Skips the remaining statements of the current iteration and starts the next iteration.
for num in range(6):
    num = num + 1

    if num == 3:
        continue

    print('Num has value ' + str(num))
break continue
Terminates the current loop. Skips the remaining part of the current iteration.
Control moves outside the loop. Control moves to the next iteration.
Remaining iterations are not executed. The loop continues with later iterations.

6. Nested Loops

Definition: A loop inside another loop is called a nested loop.

The chapter states that any type of loop can be nested within another loop. Nested loops are used for patterns and other repeated calculations.

Nested Loop Example

for i in range(1, num + 1):
    for j in range(1, i + 1):
        print(j, end=" ")
    print()

Pattern for num = 5

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

Important Uses in the Chapter

  • Pattern generation.
  • Finding prime numbers.
  • Repeated calculations.
  • Using different loop types together.

šŸ“ Important Questions & Answers

Q1. What is flow of control?
It is the order in which statements in a program are executed.
Q2. What is selection?
Selection is decision making where one of two or more possible alternatives is selected according to a condition.
Q3. What is indentation?
Indentation is leading whitespace used by Python to define blocks and nested blocks.
Q4. Name the two looping constructs.
for and while.
Q5. What is an infinite loop?
A loop that does not reach a terminating condition.
Q6. What is range()?
A built-in Python function used to generate a sequence of integers.
Q7. Is the stop value included in range()?
No. The stop value is excluded.
Q8. What does break do?
It immediately terminates the current loop.
Q9. What does continue do?
It skips the remaining statements of the current iteration and begins the next iteration.
Q10. What is a nested loop?
A loop contained inside another loop.
Q11. Differentiate break and continue.
break exits the loop, whereas continue skips the current iteration and keeps the loop running.
Q12. Differentiate for and while.
for iterates over a range or sequence; while repeats as long as its condition is true.
Q13. What happens when a while condition is initially false?
The body of the while loop is not executed even once.
Q14. What is nested if?
An if/if..else structure placed inside another selection structure.

⚔ Quick Revision

Important Definitions

  • Flow of control: Order of program execution.
  • Selection: Decision making based on conditions.
  • Indentation: Leading whitespace used to define blocks.
  • Repetition: Repeated execution of statements.
  • for: Iterates through a range or sequence.
  • while: Executes while a condition is true.
  • break: Exits the current loop.
  • continue: Skips the current iteration.
  • Nested loop: Loop inside another loop.

Most Important Syntax

if condition:
    statement

if condition:
    statement
else:
    statement

if condition:
    statement
elif condition:
    statement
else:
    statement

for variable in sequence:
    statement

while condition:
    statement

range([start], stop[, step])

Memory Trick

FLOW → SELECT → INDENT → REPEAT → LOOP → CONTROL → NEST

Flow of Control → Selection → Indentation → Repetition → for/while → break/continue → Nested loops

Programming Practice – Chapter Focus

  1. Check eligibility using age.
  2. Print the table of a number.
  3. Find minimum and maximum of five numbers.
  4. Check leap year.
  5. Generate the sequence āˆ’5, 10, āˆ’15, 20, āˆ’25….
  6. Find the sum 1 + 1/8 + 1/27 + … + 1/n³.
  7. Find sum of digits.
  8. Check palindrome.
  9. Generate star and number patterns.
  10. Find student grade according to the given percentage table.
  11. Create the menu-driven student-information case study described in the chapter.

Final Revision

Remember: Selection is used for decisions. Repetition is used for repeated execution. Indentation defines Python blocks. for works with ranges/sequences, while works with a condition, break exits a loop, continue skips an iteration and a nested loop is a loop inside another loop.
Ā© VerakWorld | Educational Notes
verakworld.com

šŸ“ This article was researched and written by Venkatesh A, Founder of verakworld.com.

Leave a Comment