Python Interview Programs
Python Programs on Numbers:
1. Write a program to reverse an integer in Python.
2. Write a program in Python to check whether an integer is Armstrong number or not.
3. Write a program in Python to check given number is prime or not.
4. Write a program in Python to print the Fibonacci series using iterative method.
5. Write a program in Python to print the Fibonacci series using recursive method.
6. Write a program in Python to check whether a number is palindrome or not using
iterative method.
7. Write a program in Python to check whether a number is palindrome or not using
recursive method.
8. Write a program in Python to find greatest among three integers.
9. Write a program in Python to check if a number is binary?
10. Write a program in Python to find sum of digits of a number using recursion?
11. Write a program in Python to swap two numbers without using third variable?
12. Write a program in Python to swap two numbers using third variable?
13. Write a program in Python to find prime factors of a given integer.
14. Write a program in Python to add two integer without using arithmetic operator?
15. Write a program in Python to find given number is perfect or not?
16. Python Program to find the Average of numbers with explanations.
17. Python Program to calculate factorial using iterative method.
18. Python Program to calculate factorial using recursion.
19. Python Program to check a given number is even or odd.
20. Python program to print first n Prime Number with explanation.
21. Python Program to print Prime Number in a given range.
22. Python Program to find Smallest number among three.
23. Python program to calculate the power using the POW method.
24. Python Program to calculate the power without using POW function.(using for loop).
25. Python Program to calculate the power without using POW function.(using while
loop).
26. Python Program to calculate the square of a given number.
27. Python Program to calculate the cube of a given number.
28. Python Program to calculate the square root of a given number.
29. Python program to calculate LCM of given two numbers.
30. Python Program to find GCD or HCF of two numbers.
31. Python Program to find GCD of two numbers using recursion.
32. Python Program to Convert Decimal Number into Binary.
33. Python Program to convert Decimal number to Octal number.
34. Python Program to check the given year is a leap year or not.
35. Python Program to convert Celsius to Fahrenheit.
36. Python Program to convert Fahrenheit to Celsius.
37. Python program to calculate Simple Interest with explanation.
Python Programs on String:
1. Python program to remove given character from String.
2. Python Program to count occurrence of a given characters in string.
3. Python Program to check if two Strings are Anagram.
4. Python program to check a String is palindrome or not.
5. Python program to check given character is vowel or consonant.
6. Python program to check given character is digit or not.
7. Python program to check given character is digit or not using isdigit() method.
8. Python program to replace the string space with a given character.
9. Python program to replace the string space with a given character using replace()
method.
10. Python program to convert lowercase char to uppercase of string.
11. Python program to convert lowercase vowel to uppercase in string.
12. Python program to delete vowels in a given string.
13. Python program to count the Occurrence Of Vowels & Consonants in a String.
14. Python program to print the highest frequency character in a String.
15. Python program to Replace First Occurrence Of Vowel With ‘-‘ in String.
16. Python program to count alphabets, digits and special characters.
17. Python program to separate characters in a given string.
18. Python program to remove blank space from string.
19. Python program to concatenate two strings using join() method.
20. Python program to concatenate two strings without using join() method.
21. Python program to remove repeated character from string.
22. Python program to calculate sum of integers in string.
23. Python program to print all non repeating character in string.
24. Python program to copy one string to another string.
25. Python Program to sort characters of string in ascending order.
26. Python Program to sort character of string in descending order.
Python Programs on Array:
1. Write a program in Python for, In array 1-100 numbers are stored, one number is
missing how do you find it.
2. Write a program in Python for, In a array 1-100 multiple numbers are duplicates, how
do you find it.
3. Write a program in Python for, How to find all pairs in array of integers whose sum is
equal to given number.
4. Write a program in Python for, How to compare two array is equal in size or not.
5. Write a program in Python to find largest and smallest number in array.
6. Write a program in Python to find second highest number in an integer array.
7. Write a program in Python to find top two maximum number in array?
8. Write a program in Python to remove duplicate elements form array.
9. Python program to find top two maximum number in array.
10. Python program to print array in reverse Order.
11. Python program to reverse an Array in two ways.
12. Python Program to calculate length of an array.
13. Python program to insert an element at end of an Array.
14. Python program to insert element at a given location in Array.
15. Python Program to delete element at end of Array.
16. Python Program to delete given element from Array.
17. Python Program to delete element from array at given index.
18. Python Program to find sum of array elements.
19. Python Program to print all even numbers in array.
20. Python Program to print all odd numbers in array.
21. Python program to perform left rotation of array elements by two positions.
22. Python program to perform right rotation in array by 2 positions.
23. Python Program to merge two arrays.
24. Python Program to find highest frequency element in array.
25. Python Program to add two number using recursion.
Python Programs on List:
1. Python Program to Find Largest Number in a List
2. Python Program to Find Second Largest Number in a List
3. Python Program to Print Largest Even and Largest Odd Number in a List
4. Python Program to Split Even and Odd Elements into Two Lists
5. Python Program to Find Average of a List
6. Python Program to Print Sum of Negative Numbers, Positive Even & Odd Numbers
in a List
7. Python Program to Count Occurrences of Element in List
8. Python Program to Find the Sum of Elements in a List using Recursion
9. Python Program to Find the Length of a List using Recursion
10. Python Program to Merge Two Lists and Sort it
11. Python Program to Remove Duplicates from a List
12. Python Program to Swap the First and Last Element in a List
13. Python Program to Sort a List According to the Second Element in Sublist
14. Python Program to Return the Length of the Longest Word from the List of Words
15. Python Program to Find the Number Occurring Odd Number of Times in a List
16. Python Program to Generate Random Numbers from 1 to 20 and Append Them to the
List
17. Python Program to Remove the ith Occurrence of the Given Word in a List
18. Python Program to Find the Cumulative Sum of a List
19. Python Program to Find the Union of Two Lists
20. Python Program to Find the Intersection of Two Lists
21. Python Program to Flatten a List without using Recursion
22. Python Program to Find the Total Sum of a Nested List Using Recursion
23. Python Program to Flatten a Nested List using Recursion
Python Programs on Tuples:
1. Write a program to input n numbers from the user. Store these numbers in a tuple.
Print the maximum and minimum number from this tuple.
2. Python Program to Create a List of Tuples with the First Element as the Number and
Second Element as the Square of the Number
3. Python Program to Remove All Tuples in a List Outside the Given Range
4. Python Program to Sort a List of Tuples in Increasing Order by the Last Element in
Each Tuple
Python Programs on Dictionary:
1. Python Program to Create Dictionary from an Object
2. Python Program to Check if a Key Exists in a Dictionary or Not
3. Python Program to Add a Key-Value Pair to the Dictionary
4. Python Program to Find the Sum of All the Items in a Dictionary
5. Python Program to Multiply All the Items in a Dictionary
6. Python Program to Remove a Key from a Dictionary
7. Python Program to Concatenate Two Dictionaries
8. Python Program to Map Two Lists into a Dictionary
9. Python Program to Create a Dictionary with Key as First Character and Value as
Words Starting with that Character
10. Python Program to Create Dictionary that Contains Number
11. Python Program to Count the Frequency of Each Word in a String using Dictionary
Python Programs on Sets:
1. Find the size of a Set in Python
2. Iterate over a set in Python
3. Python - Maximum and Minimum in a Set
4. Python - Remove items from Set
5. Python - Check if two lists have at-least one element common
6. Python program to find common elements in three lists using sets
7. Python - Find missing and additional values in two lists
8. Python program to find the difference between two lists
9. Python Set difference to find lost element from a duplicated array
10. Python program to count number of vowels using sets in given string
11. Concatenated string with uncommon characters in Python
12. Python - Program to accept the strings which contains all vowels
13. Python - Check if a given string is binary string or not
14. Python set to check if string is panagram
15. Python Set - Pairs of complete strings in two sets
16. Python program to check whether a given string is Heterogram or not
Python Programs on Classes & Objects:
1. Python Program to Create a Class which Performs Basic Calculator Operations
2. Python Program to Append, Delete and Display Elements of a List using Classes
3. Python Program to Find the Area of a Rectangle using Classes
4. Python Program to Find the Area and Perimeter of the Circle using Class
5. Python Program to Create a Class in which One Method Accepts a String from the
User and Another Prints it
6. Python Program to Create a Class and Get All Possible Distinct Subsets from a Set
Python Programs on File Handling:
1. Python Program to Read the Contents of the File
2. Python Program to Copy One File to Another File
3. Python Program to Count the Number of Lines in Text File
4. Python Program to Count the Number of Blank Spaces in a Text File
5. Python Program to Count the Occurrences of a Word in a Text File
6. Python Program to Count the Number of Words in a Text File
7. Python Program to Capitalize First Letter of Each Word in a File
8. Python Program to Counts the Number of Times a Letter Appears in the Text File
9. Python Program to Extract Numbers from Text File
10. Python Program to Print the Contents of File in Reverse Order
11. Python Program to Append the Content of One File to the End of Another File
12. Python Program to Read a String from the User and Append it into a File
Python Programs on Different Types of Patterns:
References:
https://www.sanfoundry.com/python-problems-solutions/
https://www.sanfoundry.com/1000-python-questions-answers/#