Python Practice Questions Part -1
- Anubhav Somani
- Sep 1
- 2 min read

Here are some Python coding questions ranging from beginner to intermediate levels to practice your skills.
## Beginner Level
1. Reverse a String 📝
Write a Python function that takes a string as input and returns the string reversed.
Example Input: "hello"
Example Output: "olleh"
Hint: You can solve this using slicing or a loop.
2. Palindrome Check 🔄
Write a function that checks if a given string is a palindrome. A palindrome is a word, phrase, or sequence that reads the same backward as forward.
Example Input: "madam"
Example Output: True
Example Input: "python"
Example Output: False
Hint: Consider making the string lowercase and removing spaces to handle phrases like "A man a plan a canal Panama".
## Intermediate Level
3. 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 which are multiples of both three and five, print "FizzBuzz".
Example Output Snippet:
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz ...Hint: The modulo operator (%) will be very useful here.
4. Find the Most Frequent Element 📊
Write a function that takes a list of numbers or strings and returns the element that appears most frequently. If there's a tie, you can return any of the most frequent elements.
Example Input: [1, 3, 3, 2, 1, 3, 4, 3]
Example Output: 3
Hint: A dictionary or Python's collections.Counter is a great way to store the frequency of each element.
5. The Two Sum Problem 🎯
Given a list of integers nums and an integer target, write a function that returns the indices of the two numbers in the list that add up to the target. You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example Input: nums = [2, 7, 11, 15], target = 9
Example Output: [0, 1] (Because nums[0] + nums[1] == 9)
Hint: A brute-force approach uses nested loops. For a more efficient solution, think about
how a dictionary could help you store numbers you've already seen and their indices.
Answers -

Comments