Total Pageviews

Saturday, September 5, 2026

saptarshi srija

🚗
🤖
🗼 💻 🖥️ 🧠
🖥️
🗼
✨ Computer Science Examination Assessment ✨

COMPUTISM LAB 

 HALF YEARLY EXAMINATION

Loops in Python & Advanced Control Structures

🧠
🤖
Standard: Python Programming
Max Marks: 100
Time Allowed: 3 Hours
Section A: Fill in the Blanks10 Marks
  1. The statement is used to terminate the loop prematurely even if the condition is not met.
  2. In Python, you can have an else block with a loop that is executed when the loop completes .
  3. The statement acts as an empty placeholder that does not do anything.
  4. A loop in Python is used to repeatedly execute a block of code as long as a specified condition remains True.
  5. To iterate over each character in a string using a for loop, we use the syntax .
  6. The statement skips the current iteration and moves to the next iteration.
  7. In a while loop, the condition is evaluated at the of each iteration.
  8. Multi-dimensional data handling can be efficiently achieved using loops.
  9. Python's famous Zen philosophy emphasizes that counts.
  10. The control variable in a range-based for loop automatically updates with each .
Section B: Multiple Choice Questions (MCQs)10 Marks
  1. Why do we use loops in Python?
    • a. To make the code look longer
    • b. To execute code only once
    • c. To automate repetitive tasks
    • d. To slow down execution
  2. Which type of loop is used to repeat a set of instructions for a specific number of times?
    • a. When loop
    • b. For loop
    • c. Repeat loop
    • d. Infinite loop
  3. What does the break statement do in a loop?
    • a. Skips current iteration
    • b. Continues the loop
    • c. Exits loop prematurely
    • d. Restarts program
  4. What is the purpose of the else block in a loop?
    • a. Handles errors
    • b. Executes on normal completion
    • c. Runs on break
    • d. Loops infinitely
  5. Which statement is used when we want to do nothing in code blocks?
    • a. pass
    • b. continue
    • c. break
    • d. skip
  6. What will be the output of `range(1, 6)` in a for loop?
    • a. 1, 2, 3, 4, 5, 6
    • b. 1, 2, 3, 4, 5
    • c. 0, 1, 2, 3, 4, 5
    • d. 2, 3, 4, 5, 6
  7. Which loop checks the condition before entering the block?
    • a. while loop
    • b. do-while loop
    • c. repeat-until loop
    • d. infinite loop
  8. What happens if a while loop's condition never becomes False?
    • a. Syntax Error
    • b. Indentation Error
    • c. Infinite Loop
    • d. Normal Termination
  9. Which keyword is used to skip the rest of the code for current iteration?
    • a. break
    • b. continue
    • c. pass
    • d. exit
  10. Nested loops refer to:
    • a. Loops inside another loop
    • b. Parallel loops
    • c. Syntax error loops
    • d. Conditionless loops
Section C: Assertion-Based MCQs10 Marks
  1. Assertion (A): The `break` statement terminates the loop immediately when executed.
    Reason (R): It transfers control to the statement immediately following the loop.
    a) Both A and R are true, and R is the correct explanation of A.
    b) Both are true, but unrelated.
    c) A is true, R is false.
    d) A is false, R is true.
  2. Assertion (A): A `while` loop is best used when the exact number of iterations is known in advance.
    Reason (R): The `for` loop is specifically designed for iterating over sequences like strings or ranges.
    a) Both A and R are true.
    b) A is true, but R is false.
    c) A is false, but R is true.
    d) Both A and R are false.
  3. Assertion (A): The `pass` statement in Python causes a syntax error if left empty inside a loop.
    Reason (R): `pass` acts as a null statement or placeholder that does nothing when executed.
    a) Both are true.
    b) A is true, R is false.
    c) A is false, but R is true.
    d) Both are false.
  4. Assertion (A): An `else` block associated with a `for` loop executes even if a `break` statement terminates the loop.
    Reason (R): The loop-else block only executes when the loop finishes all iterations normally without breaking.
    a) Both A and R are true, and R is the correct explanation of A.
    b) A is true, R is false.
    c) A is false, but R is true.
    d) Both are false.
  5. Assertion (A): Infinite loops are always desirable in standard application programming.
    Reason (R): They consume CPU resources continuously without terminating unless interrupted.
    a) Both are true.
    b) A is true, R is false.
    c) A is false, but R is true.
    d) Both are false.
  6. Assertion (A): The `continue` statement skips remaining statements inside the loop for the current iteration.
    Reason (R): It jumps directly to the evaluation of the loop condition or next item.
    a) Both A and R are true, and R is the correct explanation of A.
    b) A is true, R is false.
    c) A is false, but R is true.
    d) Both are false.
  7. Assertion (A): Python allows loops to be nested inside one another.
    Reason (R): Nested loops are useful for working with multi-dimensional data structures like tables.
    a) Both A and R are true, and R is the correct explanation of A.
    b) Both are true, unrelated.
    c) A is true, R is false.
    d) A is false, R is true.
  8. Assertion (A): The initialization of the loop control variable is automatically handled in a standard `for` loop using `range()`.
    Reason (R): The `range()` function generates the sequence of numbers used by the loop automatically.
    a) Both A and R are true, and R is the correct explanation of A.
    b) A is true, R is false.
    c) A is false, R is true.
    d) Both are false.
  9. Assertion (A): A `while` loop will never execute its code block if the initial condition evaluates to False.
    Reason (R): The condition is tested prior to entering the loop body.
    a) Both A and R are true, and R is the correct explanation of A.
    b) Both are true, unrelated.
    c) A is true, R is false.
    d) A is false, R is true.
  10. Assertion (A): Using meaningful variable names in loops enhances code readability.
    Reason (R): Python's core design philosophy emphasizes code clarity and readability.
    a) Both A and R are true, and R is the correct explanation of A.
    b) Both are true, unrelated.
    c) A is true, R is false.
    d) A is false, R is true.
Section D: True or False10 Marks
  1. The `break` statement stops the loop execution immediately. (True / False)
  2. A `for` loop in Python cannot iterate through characters of a string. (True / False)
  3. The `else` block with a loop runs when the loop terminates via a `break` statement. (True / False)
  4. The `pass` statement is used as a temporary placeholder in code blocks. (True / False)
  5. A `while` loop requires the condition to eventually become False to avoid an infinite loop. (True / False)
  6. Nested loops mean having a loop inside another loop. (True / False)
  7. The `continue` statement exits the entire loop immediately. (True / False)
  8. Python's `range(1, 11)` generates numbers from 1 to 10. (True / False)
  9. Infinite loops are useful when creating servers that must run continuously. (True / False)
  10. Indentation is critical for defining the body of loops in Python. (True / False)
Section E: Short Answer Questions (2 Marks Each)10 Marks
  1. What is the difference between `break` and `continue` statements in Python loops?
  2. Explain the purpose of the `else` block used with loops in Python.
  3. What is an infinite loop? Give one scenario where it can occur accidentally.
  4. Define nested loops. Give a brief practical use case.
  5. What is the role of the `pass` statement in Python programming?

Section F: Python Programming Tasks (Final Question)25 Marks
  1. Program 1: Using `break` statement
  2. Program 2: Using `while` loop print all even no from 1 to 100
  3. Program 3: Using `continue` statement
  4. Program 4: Print all letter in new line of a String 
  5. Program 5: Loop with Else Block
    Write a Python program  that searches for a target number in a list and prints confirmation messages.
⭐ Best of Luck for Your Examination! Code with Confidence! 🚀
CREATED BY BIJAN KRISHNA PAUL

No comments:

Post a Comment