Easy Level

  1. Basic If Statement:

    Write a short Python snippet using an if statement to check whether a variable (choose any name and number) is positive. If it is, print "Positive"; otherwise, print "Not positive."

    Hint: Use an if-else structure to handle both cases.

  2. Simple For Loop with Range:

    Write a Python code snippet that uses a for loop with the range() function to print the numbers 0 to 4. Next, modify the loop to only print odd numbers by incorporating the continue statement.

  3. While Loop Fundamentals:

    Write a Python while loop that prints "Hello" exactly three times. Explain briefly what condition controls your loop termination.


Medium Level

  1. Even/Odd Checker:

    Write a Python script that asks the user for an integer and then prints whether the number is even or odd. Use conditional statements (if-else) and include code to convert the user’s input (initially a string) into an integer.

    Explain how the conversion and decision-making process works in your code.

  2. Nested Loop – Vowel Counter:

    Create a Python program that uses nested loops to process a list of strings. For each string, iterate over its characters and count the vowels (a, e, i, o, u). Print each string along with its vowel count.

    In your answer, describe your approach and why nested loops are useful for this task.

  3. For Loop with Else Clause:

    Write a Python for loop that iterates over a list of numbers. If it finds a number divisible by 7, it should immediately break out of the loop. If the loop completes without finding such a number, use the else clause to print "No multiples of 7 were found."

    Explain how the else clause in a loop works in this context.


Hard Level

  1. Pattern Generation with Nested Loops:

    Write a Python program using nested loops and conditional statements that generates a pattern (e.g., a triangle of stars) based on an input value N from the user.

  2. Break vs. Continue – Comparative Analysis:

    Provide a written explanation (200–300 words) that discusses how the break and continue statements can alter the flow of a loop. Include specific code examples that demonstrate scenarios where each statement is advantageous.


Grand Test

  1. Design and Implementation Challenge:Task: Develop a Python program that integrates all the control structures discussed. Your program should:**Instructions:**Note: This task is intended to reflect your understanding and creativity. Your solution must be in your own words and represent your personal coding style and insights.