Python-language-question

Level: Intermediate

1. Write a Python program to find the second largest number in a list.
2. Write a Python program to find the second smallest number in a list.
3. Write a Python program to check if a list is empty.
4. Write a Python program to clone or copy a list.
5. Write a Python program to find the length of a list.
6. Write a Python program to remove duplicates from a list.
7. Write a Python program to find the common elements between two lists.
8. Write a Python program to remove all occurrences of a specific item from a list.
9. Write a Python program to check if a list contains a sublist.
10. Write a Python program to find the maximum and minimum values in a dictionary.
11. Write a Python program to merge two dictionaries.
12. Write a Python program to convert a list of tuples into a dictionary.
13. Write a Python program to sort a dictionary by key.
14. Write a Python program to sort a dictionary by value.
15. Write a Python program to concatenate two lists.
16. Write a Python program to create a tuple with different data types.
17. Write a Python program to convert a tuple to a string.
18. Write a Python program to find the length of a tuple.
19. Write a Python program to reverse a tuple.
20. Write a Python program to convert a list to a tuple.
21. Write a Python program to check if an element exists within a tuple.
22. Write a Python program to find the index of an item in a tuple.
23. Write a Python program to convert a tuple to a dictionary.
24. Write a Python program to unzip a list of tuples into individual lists.
25. Write a Python program to find the first non-repeating character in a string.
26. Write a Python program to count the frequency of each character in a string.
27. Write a Python program to find the longest word in a string.
28. Write a Python program to remove the nth index character from a non-empty string.
29. Write a Python program to change a given string to a new string where the first and last characters have been exchanged.
30. Write a Python program to remove characters that have odd index values in a given string.
31. Write a Python program to count the occurrences of each word in a given sentence.
32. Write a Python program to capitalize the first and last letters of each word in a string.
33. Write a Python program to compute the sum of the digits in a given string.
34. Write a Python program to add 'ing' at the end of a given string (length should be at least 3). If the given string already ends with 'ing' then add 'ly' instead.
35. Write a Python program to find the length of the longest substring without repeating characters.
36. Write a Python program to find all the anagrams in a list of strings.
37. Write a Python program to find the common divisors of two numbers.
38. Write a Python program to find the least common multiple of two numbers.
39. Write a Python program to calculate the square of a number using a lambda function.
40. Write a Python program to find the intersection of two lists.
41. Write a Python program to find the union of two lists.
42. Write a Python program to flatten a shallow list.
43. Write a Python program to sort a list of tuples by the second item.
44. Write a Python program to get the difference between the two lists.
45. Write a Python program to convert a list of characters into a string.
46. Write a Python program to get unique values from a list.
47. Write a Python program to create a list of empty dictionaries.
48. Write a Python program to create a list of all the values in a dictionary.
49. Write a Python program to get the frequency of the elements in a list.

Beginner Level: View

Advanced Level: View