Python Coding Problems Part-1


1. FizzBuzz:

Write a program that prints the numbers from 1 to 100. But for multiples of three, print "Fizz" instead of the number, and for the multiples of five, print "Buzz." For numbers that are multiples of both three and five, print "FizzBuzz."


2. Palindrome Check:

Write a function that checks if a given string is a palindrome (reads the same backward as forward). Ignore spaces, punctuation, and capitalization.


3. Factorial:

Write a function to calculate the factorial of a non-negative integer entered by the user.


4. Fibonacci Series:

Write a function to generate the Fibonacci series up to a specified number 'n'.


5. Prime Number Check:

Write a function to check if a given number is a prime number.


6. Anagram Check:

Write a function that takes in two strings and checks if they are anagrams (contain the same characters in any order).


7. Count Words in a String:

Write a function that takes a sentence as input and returns the count of each word in the sentence.


8. Binary Search:

Write a function to perform a binary search on a sorted list and return the index of the target element if found; otherwise, return -1.


9. Sum of Digits:

Write a function that takes an integer as input and returns the sum of its digits.


10. Reverse Words in a Sentence:

Write a function that takes a sentence as input and returns the sentence with the order of words reversed.


11. Matrix Transpose:

Write a function to find the transpose of a given matrix (2D list).


12. Common Elements:

Write a function that takes two lists as input and returns a new list containing the common elements between them.


13. Longest Consecutive Subsequence:

Write a function that takes a list of integers and returns the length of the longest consecutive subsequence of elements (numbers that are adjacent to each other).


14. Find Missing Number:

Write a function that takes a list of integers containing numbers from 1 to N (where N is the length of the list) with one missing number and returns the missing number.


15. Parentheses Balance:

Write a function to check if a given expression has balanced parentheses (i.e., each opening parenthesis has a corresponding closing parenthesis).


These coding problems cover a wide range of topics and will help you practice various Python concepts. Happy coding!

AJ Blogs

Hello everyone, My name Arth and I like to write about what I learn. Follow My Website - https://sites.google.com/view/aj-blogs/home

Post a Comment

Previous Post Next Post
Best Programming Books

Facebook

AJ Facebook
Checkout Our Facebook Page
AJ Blogs
Checkout Our Instagram Page