Interview Questions and Answers
Freshers / Beginner level questions & answers
Ques 1. Write a function to reverse a string.
def reverse_string(input_str):
return input_str[::-1]
Example:
reverse_string('hello') # Output: 'olleh'
Save For Revision
Save For Revision
Bookmark this item, mark it difficult, or place it in a revision set.
Log in to save bookmarks, difficult questions, and revision sets.
Ques 2. Implement a function to check if a string is a palindrome.
def is_palindrome(input_str):
return input_str == input_str[::-1]
Example:
is_palindrome('radar') # Output: True
Save For Revision
Save For Revision
Bookmark this item, mark it difficult, or place it in a revision set.
Log in to save bookmarks, difficult questions, and revision sets.
Ques 3. Write a Python function to check if a given year is a leap year.
def is_leap_year(year):
return (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)
Example:
is_leap_year(2024) # Output: True
Save For Revision
Save For Revision
Bookmark this item, mark it difficult, or place it in a revision set.
Log in to save bookmarks, difficult questions, and revision sets.
Ques 4. Implement a function to find the maximum element in a list.
def find_max_element(lst):
return max(lst)
Example:
find_max_element([3, 7, 2, 8, 5]) # Output: 8
Save For Revision
Save For Revision
Bookmark this item, mark it difficult, or place it in a revision set.
Log in to save bookmarks, difficult questions, and revision sets.
Ques 5. Write a Python program to count the occurrences of each element in a list.
from collections import Counter
def count_occurrences(lst):
return Counter(lst)
Example:
Save For Revision
Save For Revision
Bookmark this item, mark it difficult, or place it in a revision set.
Log in to save bookmarks, difficult questions, and revision sets.
Ques 6. Create a function to check if a given string is an anagram of another string.
def is_anagram(str1, str2):
return sorted(str1) == sorted(str2)
Example:
Save For Revision
Save For Revision
Bookmark this item, mark it difficult, or place it in a revision set.
Log in to save bookmarks, difficult questions, and revision sets.
Ques 7. Implement a function to remove duplicates from a list.
def remove_duplicates(lst):
return list(set(lst))
Example:
Save For Revision
Save For Revision
Bookmark this item, mark it difficult, or place it in a revision set.
Log in to save bookmarks, difficult questions, and revision sets.
Most helpful rated by users:
- Implement a function to find the maximum element in a list.
- Write a function to reverse a string.
- Implement a function to check if a string is a palindrome.
- Write a Python function to check if a given year is a leap year.
- Create a generator function to generate Fibonacci numbers.
Related interview subjects
| Embedded C interview questions and answers - Total 30 questions |
| C++ interview questions and answers - Total 142 questions |
| VBA interview questions and answers - Total 30 questions |
| COBOL interview questions and answers - Total 50 questions |
| R Language interview questions and answers - Total 30 questions |
| Python Coding interview questions and answers - Total 20 questions |
| Scala interview questions and answers - Total 48 questions |
| Swift interview questions and answers - Total 49 questions |
| Golang interview questions and answers - Total 30 questions |