Competency-Based Python Programming Questions

  1. Write a Python program using an if-else statement to determine if a number entered by the user is even or odd. Print “Even” or “Odd” accordingly.
  2. Using a for loop with range(), create a program that prints the multiplication table for a number provided by the user (up to 10 times).
  3. Develop a simple script with a while loop to keep asking the user for input until they enter the word “stop”. Print each input received.
  4. Given a string input, use string slicing to print the first three characters and the last three characters separately.
  5. Create a list of five fruits entered by the user, then use a loop to print each fruit on a new line.
  6. Write a program that uses if-elif-else to classify a student’s grade: A (90+), B (80-89), C (70-79), D (60-69), or F (below 60). Take the score as input.
  7. Using nested for loops, generate a pattern of numbers like a multiplication table grid from 1 to 5.
  8. Take a string sentence as input, then use string methods like split() and len() to count and print the total number of words and the average word length.
  9. Create a list of 10 numbers from user input, then use built-in functions to sort the list in descending order and print the sorted list along with its maximum value.
  10. Write a program with a while loop and break statement to simulate a guessing game: Generate a random number between 1 and 10 (use random module if allowed, or hardcode), and let the user guess until correct or they type “quit”.
  11. Using if-elif-else and loops, write a program to check if a given number is prime. Take input and print “Prime” or “Not Prime” with the factors if not prime.
  12. Develop a script with nested loops to print a diamond pattern of asterisks (*) with a height of 5 (increasing then decreasing rows).
  13. Take a string input, use string methods like replace() and count() to remove all vowels and count how many were removed, then print the modified string and count.
  14. Create two lists: one with numbers and one with strings. Use list operations like extend(), remove(), and a loop to merge them, remove duplicates, and sort the combined list.
  15. Write a program for binary search on a sorted list of numbers (user provides the list and target). Use a while loop and return the index if found, or -1 if not.
  16. Write a program using loops and conditionals to calculate the simple interest on a loan: Take principal, rate, and time as inputs, compute interest, and check if it’s affordable (e.g., less than 10% of principal).
  17. Simulate a basic weather checker: Take temperature input, use if-elif-else to classify as “Hot” (>30°C), “Warm” (20-30°C), etc., and use a loop to process multiple days’ data from a list.
  18. Create a program to track expenses: Use a list to store daily expenses entered in a loop until “done”, then calculate total, average, and use conditionals to warn if total exceeds a budget.
  19. Develop a BMI calculator: Take height and weight inputs, compute BMI using formula, and use if-elif-else to categorize as underweight, normal, overweight, etc. Process a list of multiple people’s data.
  20. Write a script to analyze word frequency in a pollution report string: Use string methods to split, lower(), and a list to count occurrences of words like “pollution”, “air”, etc., then sort and print top frequencies.

1 thought on “Competency-Based Python Programming Questions”

Leave a Reply

Your email address will not be published. Required fields are marked *