Skip to content
CY-306 · Computer Workshop (Python Programming)/Important Questions

Computer Workshop (Python Programming) (CY-306) - Important Questions

  1. Unit 310 Marks High Priority

    Write a Python program to check whether a given integer $n$ is a prime number. Use appropriate conditional statements and iterative loops, and display an explanatory message indicating whether $n$ is prime or not.

    Core program combining conditional checks and iterative traversal; frequently asked to test understanding of both concepts.

  2. Unit 37 Marks High Priority

    Write two Python functions to compute the factorial of a non-negative integer $n$: one using a $for$ loop and another using a $while$ loop. Show sample outputs for $n=5$ and $n=0$.

    Standard loop practice: two common loop constructs (for, while) are tested explicitly.

  3. Unit 37 Marks High Priority

    Write a Python program to generate the first $N$ terms of the Fibonacci series using iterative loops (no recursion). The program should accept $N$ and print the series up to $N$ terms.

    Classic iterative-pattern question; evaluates loop control and sequence generation skills.

  4. Unit 37 Marks High Priority

    Write a Python program that takes a string input and counts the number of vowels and consonants using iterative statements and conditional checks. Ignore digits, spaces and punctuation in the count.

    String processing with loops and conditional branching is commonly examined.

  5. Unit 37 Marks High Priority

    Write a Python program to check whether a given string is a palindrome using iterative statements and conditional checks. The program should ignore case and non-alphabetic characters.

    Typical question testing manipulation using loops and conditionals; appears frequently in practical exam pattern.

  6. Unit 35 Marks High Priority

    Explain the difference between the $break$, $continue$, and $pass$ statements in Python. Provide one short code example for each to illustrate its behavior inside a loop.

    Tests understanding of loop control flow keywords and their practical effects in Python programs.

  7. Unit 37 Marks High Priority

    Given the following Python code fragment, determine its output and explain the control flow (iterations and conditional branches):

    x = 0 for i in range(1, 4): for j in range(i): if i + j > 3: break x += 1 print(x)

    (Explain how many times the inner statement is executed and why.)

    Common exam pattern: given a code block with nested loops and conditionals, determine the output and explain control flow.

  8. Unit 310 Marks High Priority

    Write a Python program to sort a list of integers using the bubble sort algorithm. Use iterative statements and conditional comparisons. Display the list before and after sorting.

    Loop-nesting and conditional swapping logic; tests algorithm implementation with iterative constructs.

  9. Unit 37 Marks High Priority

    Write a Python program to print the following pattern for a given number of rows $r$ using nested loops:

    **


    ... (up to $r$ rows)

    The program should accept $r$ and print the pattern accordingly.

    Pattern printing with nested loops is a staple practical question to evaluate nested iterative logic.

  10. Unit 35 Marks High Priority

    Write a Python program to compute the sum of digits of a given non-negative integer $n$ using a $while$ loop. Show the result for $n=12345$.

    Small numeric-manipulation exercise focusing on while-loop usage and arithmetic conditioning.

Go to where you left off?

Quick Add to Notes

Save questions, your own notes and screenshots into notes filed by unit. It takes a free account.

Create free account

Have an account? Log in