CBSE/Karnataka PU Board PUC I Chapter 6 "FLOW OF CONTROL"


 

PREVIOUS CHAPTER QUESTION BANK CLICK BELOW

CHAPTER 1 

CHAPTER 2

CHAPTER 3

CHAPTER 4

CHAPTER 5 

[NOTE: Kindly cross check answers once from other source also, Quantity and Quality of answers also kindly check before use, specially 5 marks answers are not sufficient kindly add from your side, this gives just quick review]

50 MCQ questions with answers 

  1. The flow of control in Python is managed using:
    A) Comments
    B) Control structures
    C) Functions
    D) Variables
    Answer: B

  2. In Python, which construct handles decision making?
    A) for loop
    B) if statement
    C) continue statement
    D) break statement
    Answer: B

  3. The simplest flow control structure is:
    A) Selection
    B) Repetition
    C) Sequence
    D) Nested loop
    Answer: C

  4. Which keyword is used for a single alternative selection?
    A) elif
    B) if
    C) while
    D) for
    Answer: B

  5. What does indentation define in Python?
    A) Type of variable
    B) Block of code
    C) Output format
    D) Error type
    Answer: B

  6. Select the statement that is NOT a loop in Python.
    A) while
    B) for
    C) if
    D) continue
    Answer: C

  7. The operator used to compare values in an if condition is:
    A) +
    B) ==
    C) =
    D) //
    Answer: B

  8. What is the output of:

python
if 3 < 5: print("Yes") else: print("No")

A) Yes
B) No
C) True
D) Error
Answer: A

  1. Which keyword allows you to check multiple conditions?
    A) if
    B) elif
    C) while
    D) continue
    Answer: B

  2. The 'else' block is executed when:
    A) The 'if' block is true
    B) The 'if' block is false
    C) Always
    D) Never
    Answer: B

  3. Which Python statement is used for repetition?
    A) if
    B) while
    C) break
    D) elif
    Answer: B

  4. What will for i in range(3): print(i) print?
    A) 1 2 3
    B) 0 1 2
    C) 0 1 2 3
    D) 3 2 1
    Answer: B

  5. How many times will the body of a while loop while count <= 5: run if count is initialized as 1?
    A) 4
    B) 5
    C) 6
    D) infinite
    Answer: B

  6. Which function is used to generate a sequence in Python for loops?
    A) list()
    B) range()
    C) sequence()
    D) tuple()
    Answer: B

  7. What does the 'break' statement do in a loop?
    A) Skips one iteration
    B) Terminates the loop
    C) Continues next iteration
    D) Throws error
    Answer: B

  8. What does the 'continue' statement do?
    A) Exits the program
    B) Skips rest of loop block for current iteration
    C) Terminates while loop
    D) Runs next if block
    Answer: B

  9. For nested loops, the inner loop runs:
    A) Before the outer loop
    B) After the outer loop
    C) For each iteration of outer loop
    D) Only once
    Answer: C

  10. What is the output type of input() function?
    A) int
    B) float
    C) string
    D) bool
    Answer: C

  11. What will be the output of:

python
age = 17 if age >= 18: print("Adult") else: print("Minor")

A) Adult
B) Minor
C) Error
D) None
Answer: B

  1. Which symbol is used for equal comparison?
    A) =
    B) ==
    C) =>
    D) <=
    Answer: B

  2. What is the key purpose of range(start, stop, step)?
    A) Sorting values
    B) Generating sequences
    C) Repeating code
    D) Comparing values
    Answer: B

  3. What will range(1, 5, 2) generate?
    A)
    B)
    C)
    D)
    Answer: B

  4. What does 'elif' stand for?
    A) Else If
    B) Else Loop
    C) Element If
    D) Error If
    Answer: A

  5. A properly indented block avoids ___ errors.
    A) Syntax
    B) Logical
    C) Type
    D) Output
    Answer: A

  6. Which is not a valid loop type in Python?
    A) for
    B) while
    C) do-while
    D) nested
    Answer: C

  7. What value returns the termination of a while loop with condition count <= 10 if count starts at 1 and increases by 2 each time?
    A) 4 times
    B) 5 times
    C) 10 times
    D) 6 times
    Answer: D

  8. Choose the false statement:
    A) 'break' immediately exits loop block
    B) 'continue' ends entire program
    C) 'while' can cause infinite loops
    D) 'for' uses sequence
    Answer: B

  9. What is a nested loop?
    A) Loop inside a variable
    B) Loop inside a loop
    C) Loop inside a function
    D) Loop inside an if
    Answer: B

  10. What is the result of:

python
for i in range(2, 6): print(i)

A) 2, 3, 4, 5
B) 2, 3, 4, 5, 6
C) 1, 2, 3, 4, 5
D) 6, 7, 8
Answer: A

  1. The result when 0 is given for step in range():
    A) Error
    B)
    C) Infinite loop
    D) [0, 1, ...]
    Answer: A

  2. Which is default start in range(stop)?
    A) 1
    B) 0
    C) stop
    D) -1
    Answer: B

  3. Which output is generated by range(10, 20, 2)?
    A)
    B)
    C)
    D)kecs105.pdf
    Answer: A

  4. Which control allows skipping one iteration in a loop?
    A) break
    B) continue
    C) skip
    D) pass
    Answer: B

  5. What will be printed:

python
for ch in "ABC": print(ch)

A) ABC
B) A, B, C
C) Error
D) ch
Answer: B

  1. Which function converts string input to integer?
    A) str()
    B) int()
    C) float()
    D) input()
    Answer: B

  2. The outcome when 'break' is used in while True loop:
    A) Infinite loop
    B) Loop terminates immediately
    C) Loop never starts
    D) Error
    Answer: B

  3. In a loop, what is an 'iteration'?
    A) One execution of loop body
    B) Start of program
    C) Printing output
    D) Variable assignment
    Answer: A

  4. Which loop is ideal when number of iterations is known?
    A) for
    B) while
    C) nested
    D) infinite
    Answer: A

  5. How does Python treat indentation?
    A) Ignores it
    B) Requires it strictly
    C) Replaces with braces
    D) Causes runtime error
    Answer: B

  6. What is the output of:

python
i = 0 while i < 3: print(i) i += 1

A) 1 2 3
B) 0 1 2
C) 0 1 2 3
D) Error
Answer: B

  1. What does the expression if x != y: mean?
    A) x equals y
    B) x not equals y
    C) x less than y
    D) x greater than y
    Answer: B

  2. Loop that may run infinitely unless condition changes:
    A) for loop
    B) while loop
    C) continue
    D) pass
    Answer: B

  3. Which can be used to generate decreasing sequence?
    A) range(10, 0, -1)
    B) range(0, 10, -1)
    C) range(10, -1, 1)
    D) range(1, 10, -2)
    Answer: A

  4. The 'pass' statement is used for:
    A) Skipping code block
    B) Exiting loop
    C) Continuing iteration
    D) Placeholder for future code
    Answer: D

  5. The 'else' with a loop executes when:
    A) Loop ends normally
    B) Loop is broken
    C) Loop is infinite
    D) Loop contains continue
    Answer: A

  6. What data type does input() return?
    A) int
    B) float
    C) str
    D) bool
    Answer: C

  7. Which command prints numbers from 1 to 5?
    A) for i in range(1,6): print(i)
    B) for i in range(0,5): print(i)
    C) for i in range(1,5): print(i)
    D) for i in range(1,7): print(i)
    Answer: A

  8. In nested loops, exit of inner loop causes:
    A) Both loops exit
    B) Outer loop continues
    C) Program ends
    D) Next iteration starts
    Answer: B

  9. Which is NOT a Python control structure?
    A) Sequence
    B) Selection
    C) Iteration
    D) Expansion
    Answer: D

  10. Which of these can NOT be used for testing equality in Python?
    A) ==
    B) is
    C) =
    D) !=
    Answer: C

1 mark questions with answers

  1. What is the simplest flow control structure in Python?
    Answer: Sequence

  2. Which keyword is used for decision making in Python?
    Answer: if

  3. What term describes code executed line by line from start to finish?
    Answer: Sequence

  4. Which statement is used for repetition in Python?
    Answer: while

  5. Which function generates a sequence of numbers in Python?
    Answer: range()

  6. What keyword is used for multiple conditions after if?
    Answer: elif

  7. Python uses _______ to define a block of code.
    Answer: Indentation

  8. Which operator is used for equality comparison in if condition?
    Answer: ==

  9. What statement is used to exit a loop before its natural end?
    Answer: break

  10. Which statement skips the rest of a loop body for current iteration?
    Answer: continue

  11. What type does input() function return?
    Answer: String (str)

  12. What is a nested loop?
    Answer: A loop inside another loop.

  13. Which control structure allows selection between alternate paths?
    Answer: Selection (if-else)

  14. What do you call the repeated execution of program statements?
    Answer: Iteration or Looping

  15. Which key word is used to leave a code block as a placeholder?
    Answer: pass

  16. What is the output of range(3)?
    Answer: 0, 1, 2

  17. Which statement is true for while loops?
    Answer: Condition checked before iteration

  18. What happens if loop condition is always true?
    Answer: Infinite loop

  19. Which structure handles branching in Python?
    Answer: Selection (if-else)

  20. What block executes if all if/elif conditions fail?
    Answer: else

2 mark questions with answers

  1. What is the role of sequence in Python programs?
    Answer:
    Sequence ensures statements are executed one after another in the order they appear, maintaining a logical flow.

  2. Define selection in flow of control with an example.
    Answer:
    Selection allows choosing among alternative paths; e.g., if age >= 18: print("Adult") else: print("Minor").

  3. Explain the while loop structure in Python.
    Answer:
    A while loop repeats a block as long as its condition evaluates to True. Example: while x < 5: print(x); x += 1.

  4. What does the ‘break’ statement do inside loops?
    Answer:
    It instantly exits the current loop, skipping all remaining iterations of the loop body.

  5. How is indentation used in Python for flow of control?
    Answer:
    Indentation marks the start and end of code blocks, especially within loops and selection statements.

  6. Describe the use of ‘elif’ in decision making.
    Answer:
    ‘elif’ checks multiple conditions after an ‘if’ and before ‘else’, allowing complex branching.

  7. When does the else block execute after an if statement?
    Answer:
    It runs if the if and any preceding elif conditions are all False.

  8. Why is range() commonly used in for loops?
    Answer:
    range() generates sequences of numbers, enabling controlled iteration in for loops.

  9. What is a nested loop? Give an example.
    Answer:
    Loop inside another loop, e.g.,

python
for i in range(2): for j in range(2): print(i, j)
  1. What is the result of for i in range(2, 8, 2): print(i)?
    Answer:
    Prints 2, 4, 6; range produces numbers from 2 up to but not including 8, step 2.

  2. What are advantages of structured flow control in programming?
    Answer:
    It improves code clarity, logic, debugging, and maintains manageable program complexity.

  3. How can you skip the rest of a loop’s body for the current iteration?
    Answer:
    Use the continue statement to move to the next loop iteration immediately.

  4. How does Python prevent ambiguity with indentation?
    Answer:
    Mandatory indentation visually separates blocks, preventing logical and syntax errors.

  5. Give the output of:

python
if 'A' > 'B': print("First") else: print("Second")

Answer:
Second

  1. What is the effect of an infinite loop in Python?
    Answer:
    It repeatedly executes the loop body, potentially freezing the program unless forcibly stopped.

  2. Differentiate between ‘for’ and ‘while’ loops with examples.
    Answer:
    ‘for’ loop: known iterations, e.g. for i in range(3). ‘while’ loop: unknown, condition-based, e.g., while x > 0.

  3. How does the pass statement function in Python programs?
    Answer:
    Acts as a placeholder where a statement is required syntactically but no action is needed.

  4. What happens if break is applied within a nested loop’s inner loop?
    Answer:
    Only the inner loop exits; the outer loop continues its next iteration.

  5. Give the output of:

python
count = 1 while count < 4: print(count) count += 1

Answer:
1 2 3

  1. How are decision structures useful in real-life applications?
    Answer:
    They help make choices: e.g., ATM checking balance before withdrawal, login system verifying credentials.

3 mark questions with answers 

  1. Explain with code how an if-elif-else ladder works in Python.
    Answer:
    The ladder checks multiple conditions in sequence:

python
x = 15 if x < 10: print("Less than 10") elif x == 15: print("Equals 15") else: print("Greater than 10")

This prints "Equals 15".

  1. Write a Python program to print numbers 1 to 10 using a while loop.
    Answer:

python
i = 1 while i <= 10: print(i) i += 1
  1. How does indentation influence program execution in Python?
    Answer:
    Indentation defines code blocks for statements like if, for, while. Misplaced indentation causes syntax errors and changes program logic.

  2. Illustrate the use of ‘break’ and ‘continue’ with examples.
    Answer:
    ‘break’ exits loop; ‘continue’ skips to next iteration.

python
for i in range(5): if i == 3: break print(i) # prints 0,1,2 for j in range(5): if j == 3: continue print(j) # skips 3
  1. Describe the structure of a for loop in Python.
    Answer:
    for variable in sequence:
    Executes the block for each value in the sequence.

  2. Differentiate between sequence, selection, and iteration with suitable examples.
    Answer:
    Sequence: statements in order;
    Selection: if-else to choose path;
    Iteration: for/while loops for repetition.

  3. Write a nested loop to print a 3x3 matrix with numbers 1-9.
    Answer:

python
num = 1 for i in range(3): for j in range(3): print(num, end=' ') num += 1 print()
  1. How can range(start, stop, step) be used in for loops?
    Answer:
    Generates sequences; example:
    for i in range(2, 10, 2): print(i) prints 2 4 6 8.

  2. Explain what happens when the while loop’s condition is never false.
    Answer:
    It creates an infinite loop, running endlessly unless interrupted by 'break' or an external stop.

  3. Describe three logical errors that may arise using control structures.
    Answer:
    Infinite loops due to incorrect condition;
    Wrong branch chosen in if-else due to misused operators;
    Skipping loop body due to off-by-one errors.

  4. Write a code to sum numbers from 1 to 100 using a for loop.
    Answer:

python
s = 0 for i in range(1, 101): s += i print(s)
  1. State how ‘else’ behaves with a loop in Python.
    Answer:
    ‘else’ with a loop executes only if the loop was not exited by a ‘break’ statement.

  2. How does the ‘pass’ statement help in flow of control?
    Answer:
    It’s a placeholder when no action is needed, keeps block syntactically correct, especially during development.

  3. Give an example where selection is essential in a real-world Python program.
    Answer:
    ATM withdrawal: checking if balance is sufficient—if yes, dispense cash; else, show error.

  4. Write a program using nested loops to display a right-angled triangle of stars.
    Answer:

python
for i in range(1, 6): for j in range(i): print("*", end="") print()
  1. Explain how ‘break’ works in both for and while loops with example.
    Answer:
    For loop:

python
for i in range(10): if i == 4: break print(i)

While loop:

python
x = 0 while x < 10: if x == 4: break print(x) x += 1
  1. Illustrate flow of control for a number-guessing game (1-10) in Python.
    Answer:

python
import random num = random.randint(1,10) guess = int(input("Guess: ")) if guess == num: print("Correct!") elif guess < num: print("Too low") else: print("Too high")
  1. Discuss possible consequences of missing indentation in a program with control structures.
    Answer:
    Leads to syntax errors or unintended grouping of code, causing program malfunction or unpredictable results.

  2. What are nested loops used for? Give a practical example.
    Answer:
    Used to work with multi-dimensional data, e.g., printing tables, matrices, game grids.

  3. Show how to use for loop and if statement together to print even numbers from 1 to 20.
    Answer:

python
for i in range(1, 21): if i % 2 == 0: print(i)

5 mark questions with answers 

  1. Explain different types of control structures in Python with examples.
    Answer:
    Python supports three primary control structures — sequence, selection, and iteration.

  • Sequence: Code runs line by line in the order written, e.g.:

    python
    a = 5 b = 7 print(a + b)
  • Selection: Decisions through if-else or if-elif-else:

    python
    age = int(input("Enter age: ")) if age >= 18: print("Eligible") else: print("Not eligible")
  • Iteration: Repetition using for and while loops:

    python
    for i in range(5): print(i) count = 0 while count < 5: print(count) count += 1

These structures allow flexible program design and handle various logical situations.

  1. Discuss with examples the difference between break and continue statements in Python loops.
    Answer:
    The break statement ends the nearest enclosing loop instantly, while continue skips the current iteration and resumes the next.

  • break example:

    python
    for i in range(10): if i == 5: break print(i) # Prints 0 to 4
  • continue example:

    python
    for i in range(6): if i == 3: continue print(i) # Prints 0,1,2,4,5 (skips 3)

Use break to abort loops early and continue to skip certain cases but continue looping.

  1. Describe the working of if...elif...else with a program to check if a number is positive, negative, or zero.
    Answer:
    The if...elif...else chain in Python allows checking multiple conditions sequentially:

python
num = int(input("Enter a value: ")) if num > 0: print("Positive") elif num < 0: print("Negative") else: print("Zero")

This program gets a number from the user, checks its sign, and prints the result. Only one block executes, and else is the default when no condition matches.

  1. Write a program to input two numbers and perform addition, subtraction, multiplication, and division as per user’s choice. Handle division by zero.
    Answer:

python
a = float(input("Enter first number: ")) b = float(input("Enter second number: ")) op = input("Choose operator (+, -, *, /): ") if op == '+': print("Sum =", a + b) elif op == '-': print("Difference =", a - b) elif op == '*': print("Product =", a * b) elif op == '/': if b == 0: print("Error: Division by zero") else: print("Quotient =", a / b) else: print("Invalid operator")

The program performs operations as per user’s choice and handles division by zero without crashing.

  1. Explain the structure and use of for and while loops in Python. Show how to print even numbers from 1 to 20 using both loops.
    Answer:

  • For loop:

    python
    for i in range(2, 21, 2): print(i)

    Starts at 2, increments by 2, prints all even numbers till 20.

  • While loop:

    python
    i = 2 while i <= 20: print(i) i += 2

Both loops achieve the same result, but for is used when the number of iterations is known, while while handles condition-based repetition.

  1. What is indentation in Python? Explain its role and consequences of improper indentation with examples.
    Answer:
    Indentation is mandatory in Python and groups statements into blocks.
    Proper example:

python
if a > 0: print("Positive") print("Number tested") else: print("Non-positive")

Improper indentation gives:

python
if a > 0: print("Positive") print("Number tested") else: print("Non-positive")

which raises an IndentationError. Correct indentation is critical for flow control and prevents logic/syntax errors.

  1. Write a Python program that prints a pattern as follows for n = 5:

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

Explain how control structures create this pattern.
Answer:

python
n = 5 for i in range(1, n+1): for j in range(1, i+1): print(j, end=' ') print()

Outer loop (1 to n): controls rows; inner loop (1 to i): prints numbers on each row. Line break after each row. Nested loops enable construction of the pattern row by row.

  1. Define an infinite loop with an example. How can you prevent a loop from becoming infinite?
    Answer:
    An infinite loop keeps executing as its condition never becomes False.
    Example:

python
while True: print("This will run forever.")

To prevent it: ensure the loop condition will eventually fail, or use break when a specific condition is met:

python
while True: x = int(input("Enter number: ")) if x == 0: break
  1. Describe nested loops and provide a program to print a multiplication table (1 to 5).
    Answer:
    Nested loops are loops inside other loops.
    Program:

python
for i in range(1, 6): for j in range(1, 11): print(f"{i} x {j} = {i*j}") print()

Outer loop for each table (1-5), inner loop for multiples (1-10). Prints tables one after another.

  1. Write a program to input the percentage of marks and display the grade as per criteria: Above 90 = A, 80 to 90 = B, 70 to 80 = C, 60 to 70 = D, Below 60 = E. Explain the use of control structures used.
    Answer:


python
perc = float(input("Enter percentage: ")) if perc > 90: print("Grade A") elif perc >= 80: print("Grade B") elif perc >= 70: print("Grade C") elif perc >= 60: print("Grade D") else: print("Grade E")





Comments