Here are 50 fundamental programming problems in Python involving loops, if-else statements, lists, tuples, sets, and dictionaries for practice and implementation. These exercises offer a great opportunity to enhance your understanding and proficiency in basic programming concepts. By working on these problems, you can strengthen your skills in solving common programming challenges using these fundamental constructs.
1. Write a program to find the sum of all numbers from 1 to N.
2. Given a list of integers, find the maximum and minimum elements.
3. Write a program to check if a given number is prime.
4. Find the factorial of a given number.
5. Count the number of vowels in a string.
6. Check if a given string is a palindrome.
7. Reverse a given list of integers.
8. Find the second largest element in a list of integers.
9. Write a program to remove duplicates from a list.
10. Given a list of integers, find the average.
11. Check if the two lists are equal.
12. Find the intersection of two lists.
13. Given a list of integers, remove all the even numbers.
14. Given a list of strings, concatenate them into a single string.
15. Find the number of occurrences of a specific element in a list.
16. Remove the duplicates from a string.
17. Count the number of words in a sentence.
18. Write a program to check if a given string is a pangram.
19. Calculate the sum of digits in a number.
20. Given a list of integers, find the product of all the elements.
21. Check if a given number is a perfect square.
22. Find the length of the longest word in a sentence.
23. Calculate the average of all the even numbers in a list.
24. Given a list of integers, find the median.
25. Check if a given string is an anagram of another string.
26. Write a program to reverse a string.
27. Find the sum of all the even numbers between two given numbers.
28. Given a list of strings, find the longest string.
29. Remove all the special characters from a string.
30. Calculate the power of a number.
31. Check if a given number is a palindrome.
32. Given a list of integers, find the second smallest element.
33. Remove the vowels from a string.
34. Given a list of strings, find the number of words in each string.
35. Sort a list of integers in ascending order.
36. Check if all elements in a list are unique.
37. Given a list of tuples, sort them based on the second element.
38. Remove the duplicates from a list of tuples.
39. Find the most frequent element in a list.
40. Given two lists, find their common elements.
41. Calculate the sum of all the odd numbers between two given numbers.
42. Check if a given string is a valid email address.
43. Find the number of words starting with a specific letter in a sentence.
44. Given a list of integers, find the third largest element.
45. Check if a given list is sorted in non-decreasing order.
46. Find the number of prime numbers in a given range.
47. Given a list of tuples, convert it into a dictionary.
48. Check if a given string is a palindrome ignoring spaces.
49. Given a string, count the number of uppercase and lowercase letters.
50. Write a program to remove duplicate characters from a string.
These problems provide a variety of scenarios where you can apply different programming concepts. By solving them, you’ll gain familiarity and confidence in using loops, if-else statements, lists, tuples, sets, and dictionaries in Python. Additionally, solving these problems will improve your problem-solving skills and ability to break down complex tasks into smaller, manageable steps. Visit our course module on Python with Problem Solving.
.