0% found this document useful (0 votes)
3 views2 pages

Python Interview Programs Questions Expected Output

The document lists various Python coding interview questions categorized into string, number, list/array, dictionary, set/tuple, logical/tricky, file handling, exception handling, OOP, advanced Python, and QA/automation. Each question includes a specific input and the expected output. This resource serves as a guide for practicing common coding problems in Python.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Python Interview Programs Questions Expected Output

The document lists various Python coding interview questions categorized into string, number, list/array, dictionary, set/tuple, logical/tricky, file handling, exception handling, OOP, advanced Python, and QA/automation. Each question includes a specific input and the expected output. This resource serves as a guide for practicing common coding problems in Python.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Interview Coding Questions – Questions &

Expected Output

STRING PROGRAMS

1. Reverse a string | Input: python | Output: nohtyp


2. String rotation | Input: jayaram (left rotate by 3) | Output: aramjay
3. Palindrome check | Input: madam | Output: Palindrome
4. Anagram check | Input: listen, silent | Output: Anagram
5. Roman to Integer | Input: XIV | Output: 14

NUMBER PROGRAMS

6. Prime check | Input: 17 | Output: Prime


7. Fibonacci | Input: 5 | Output: 0 1 1 2 3
8. Factorial | Input: 5 | Output: 120
9. Armstrong | Input: 153 | Output: Armstrong
10. Reverse number | Input: 1234 | Output: 4321

LIST / ARRAY PROGRAMS

11. Second largest | Input: [10,20,4,45,99] | Output: 45


12. Remove duplicates | Input: [1,2,2,3,3] | Output: [1,2,3]
13. Missing number | Input: [1,2,4,5] | Output: 3
14. Pair sum | Input: [2,7,11,15], Sum=9 | Output: (2,7)
15. Flatten list | Input: [1,[2,3],[4]] | Output: [1,2,3,4]

DICTIONARY PROGRAMS

16. Word frequency | Input: apple apple banana | Output: {apple:2, banana:1}
17. Max value key | Input: {a:10,b:25,c:15} | Output: b
18. Sort by value | Input: {a:3,b:1,c:2} | Output: {b:1,c:2,a:3}
19. Merge dicts | Input: {a:1},{b:2} | Output: {a:1,b:2}

SET / TUPLE PROGRAMS

20. Common elements | Input: [1,2,3],[2,3,4] | Output: {2,3}


21. Tuple to list | Input: (1,2,3) | Output: [1,2,3]
LOGICAL / TRICKY

22. Balanced brackets | Input: ((())) | Output: Balanced


23. Most frequent element | Input: [1,2,2,3] | Output: 2
24. Longest word | Input: Python is easy | Output: Python

FILE HANDLING

25. Count words | File: Hello World Python | Output: 3


26. Search word | Word: Python | Output: Found

EXCEPTION HANDLING

27. Division by zero | Input: 10/0 | Output: Exception handled

OOPS

28. Inheritance | Output: Parent method called, Child method called


29. Method overriding | Output: Child implementation

ADVANCED PYTHON

30. List comprehension | Input: [1,2,3] | Output: [1,4,9]


31. Generator | Input: range(3) | Output: 0 1 2

QA / AUTOMATION

32. Random string length 5 | Output: aB3xP


33. JSON parsing | Input: {status:200,message:Success} | Output: Success

You might also like