Python Control Structures - Assignment Questions

Basic Level (10 Questions)

  1. Write a Python program to check if a number is positive, negative, or zero using if statement.
  2. Write a program to find the largest of two numbers using if-else.
  3. Write a program to print all numbers from 1 to 10 using a while loop.
  4. Print all even numbers between 1 and 20 using a for loop.
  5. Write a program to check whether a number is even or odd.
  6. Write a program to print the multiplication table of a given number using a for loop.
  7. Write a program to find the factorial of a number using a while loop.
  8. Write a program to print the first 10 natural numbers using a for loop.
  9. Write a program to find the sum of all numbers from 1 to n, where n is input from the user.
  10. Write a program to check if a character is a vowel or consonant using if-else.

Intermediate Level (10 Questions)

  1. Write a program to find the largest among three numbers using if-elif-else.
  2. Write a program to print all prime numbers between 1 and 100 using for loop and if conditions.
  3. Write a program to calculate the sum of digits of a given number using a while loop.
  4. Write a program to reverse a given number using a while loop.
  5. Write a program to print a pyramid pattern of stars using nested for loops.
  6. Write a program to check if a string is a palindrome using for loop.
  7. Write a program to generate Fibonacci series up to n terms using a while loop.
  8. Write a program to find the GCD (Greatest Common Divisor) of two numbers using while loop.
  9. Write a program to find the factorial of a number using recursion (use if-else for base case).
  10. Write a program to count the number of vowels in a given string using a for loop.

Advanced Level (10 Questions)

  1. Write a program to print all Armstrong numbers between 100 and 999 using nested loops.
  2. Write a program to implement a basic calculator using if-elif-else for operations (+, -, *, /).
  3. Write a program to print Pascal’s triangle up to n rows using nested loops.
  4. Write a program to find the sum of even and odd numbers separately from a list of numbers.
  5. Write a program to merge two sorted lists into a single sorted list using loops.
  6. Write a program to simulate a number guessing game where the user has limited attempts.
  7. Write a program to print the pattern of numbers like:
    1
    12
    123
    1234
    using nested loops.
  8. Write a program to find the first n prime numbers using loops.
  9. Write a program to remove duplicate elements from a list without using set().
  10. Write a program to check whether a given year is a leap year or not using control structures.