You are on page 1of 6

UNIT II INTRODUCTION TO PYTHON

Python Introduction, Technical Strength of Python, Python interpreter and interactive mode,
Introduction to colab , pycharm and jupyter idle(s) ,Values and types: int, float, boolean,
string, and list; Built-in data types, variables, Literals, Constants, statements, Operators:
Assignment, Arithmetic, Relational, Logical, Bitwise operators and their precedence,
Expressions, tuple assignment, Accepting input from Console, printing statements, Simple
Python programs.

UNIT III CONTROL FLOW, FUNCTIONS AND STRINGS


Conditionals: Boolean values and operators, conditional (if), alternative (if-else), chained
conditional (if-elif-else); Iteration: while, for; Loop manipulation using pass, break, continue,
and else; Modules and Functions: function definition and use, flow of execution, parameters
and arguments, local and global scope, return values, function composition, recursion.
Strings: string slices, immutability, string functions and methods, string module; Illustrative
programs: square root, gcd, exponentiation, sum an array of numbers, linear search, binary
search.

UNIT IV LISTS, TUPLES, DICTIONARIES


Lists: Defining list and list slicing, list operations, list slices, list methods, list loop, list
Manipulation, mutability, aliasing, cloning lists, list parameters, lists as arrays. Tuples: tuple
assignment, tuple as return value, tuple Manipulation; Dictionaries: operations and methods;
advanced list processing – list comprehension; Illustrative programs: selection sort, insertion
sort, merge sort, histogram.

UNIT V FILES, MODULES, PACKAGES


Files and exception: Concept of Files, Text Files; File opening in various modes and closing
of a file, Format Operators, Reading from a file, Writing onto a file, File functions- open(),
close(), read(),readline(), readlines(),write(), writelines(),tell(),seek(), Command Line
arguments; Errors and exceptions: handling exceptions; modules, packages; introduction to
numpy, matplotlib. Illustrative programs: word count, copy a file.
1.
Python Problem Solving Questions
BASICS

Easy

1. Write a program to calculate the sum of two numbers.

2. Write a program to calculate the area of a circle.

3. Write program to calculate the area of a triangle given its base and height.

4. Write a program to calculate the area of a trapezoid.

5. Write a program to calculate the volume of a sphere given its radius.

6. Write a program to calculate simple interest

CONDITIONAL & LOOPS STATEMENTS

Easy

7. Create a program to check whether the given number is even or odd.

8. Write a program to find the maximum of three numbers.

9. Write a program to find the factorial of a number

10. Write a program to print the Fibonacci sequence up to a given number of terms.

11. Write a program to calculate the sum of the digits of a given number.

12. Write a program to reverse the number.

13. Write a program to check whether the given number is palindrome or not.

14. Write a program to check whether the given number is Armstrong Number or Not.

Medium

15. Write a program to print ASCII Value of a character

16. Write a program to check whether the number is prime or not.

17. Write a program to find the Sum of squares of first n natural numbers

18. Write a program to find the cube sum of first n natural numbers

FUNCTIONS

Easy

19. Write a program to find the factorial of a number using a function.


20. Create a function that checks if a number is prime or not.

21. Create a function to check if a given year is a leap year.

22. Create a function to find the largest prime factor of a given number.

23. Create a function to calculate the sum of all elements in a list.

24. Implement a function to check if a number is a perfect number.

Medium

25. Create a function to check if a string is an anagram of another string.

26. Write code to find the square root of a number using the Newton-Raphson method.

27. Write a program to find the GCD (Greatest Common Divisor) of two numbers.

28. Write a Python program to find the LCM (Least Common Multiple) of two numbers.

29. Create a function to check if a string contains only digits.

Hard

30. Implement a Huffman coding algorithm for text compression.

RECURSION

31. Write a program to find the factorial of a number using recursion.

32. Create a program to solve the Tower of Hanoi puzzle using recursion.

33. Create a program to calculate the power of a number using recursion.

OPERATORS

Easy

34. Implement a simple calculator program that supports multiple operations and
follows the order of operations (PEMDAS/BODMAS).

35. Create a program to print a pattern of asterisks in the shape of a right-angled


triangle.

MATRIX

Medium

36. Write a program to perform matrix addition and subtraction.

37. Create a program to perform matrix multiplication.

38. Write a program to get Kth Column of a Matrix

39. Write a program to perform matrix transposition.


Hard

40. Write a program to calculate the determinant of a 3x3 matrix.

41. Write a program to find the inverse of a 3x3 matrix.

STRING

Easy

42. Write a python program to reverse a string.

43. Write a program to check if a given string is a palindrome.

44. Write a python script to count the number of vowels in a string.

45. Write a program to remove all whitespace from a string.

46. Write a program to remove i’th character from string in Python

47. Write a program to Check if a Substring is Present in a given String

48. Write a program to Count the Number of matching characters in a pair of string

49. Write a program to find Maximum frequency character in String

50. Implement a function to find the first non-repeated character in a string.

51. Implement a function to check if a string contains only uppercase letters.

52. Write a Python Program to Remove Punctuations From a String

Medium

53. Create a function to reverse words in a given sentence.

54. Create a program to generate a random password of a specified length.

55. Write code to find the length of the longest word in a sentence.

56. Write code to find the longest common subsequence (LCS) between two strings.

57. Implement a function to calculate the edit distance between two strings (Levenshtein
distance).

58. Create a program to reverse a sentence word by word while preserving whitespace.

LIST AND TUPLES

Easy

59. Write a program to interchange first and last elements in a list

60. Write a program to swap two elements in a list


61. Write a program to find length of list

62. Write a program to check if element exists in list

63. Write a program to calculate the sum of all elements in a list.

64. Write a program to find the largest element in a list.

65. Write a program to print even numbers in a list

66. Write a program to print odd numbers in a List

67. Write a program to print all even numbers in a range

68. Write a program to print all odd numbers in a range

69. Write a program to print positive numbers in a list

70. Write a program to print negative numbers in a list

71. Write a program to print all positive numbers in a range

72. Write a Python function to remove duplicates from a list.

73. Write a program to find the second largest element in a list.

74. Write code to calculate the average of numbers in a list.

75. Write a program to reverse a list.

76. Write a program to find the intersection of two lists.

77. Write a python program to find the sum of all even numbers in a list.

Medium

78. Write a Python script to sort a list of strings based on their length.

79. Implement a binary search algorithm to find an element in a sorted list.

80. Implement a bubble sort algorithm to sort a list.

81. Write a program to merge two sorted lists into a single sorted list.

82. Write a program to generate all possible permutations of a string.

83. Implement a selection sort algorithm to sort a list.

84. Create a program to find the mode (most frequent element) in a list.

Hard

85. Implement a merge sort algorithm to sort a list.

86. Write a program to find the longest increasing subsequence in a list.

DICTIONARY
Medium

87. Write a program to find the sum of all items in a dictionary

88. Write a program to find the sum of all items in a dictionary

89. Write a program to Remove all duplicates words from a given sentence

90. Write a program to Convert a list of Tuples into Dictionary

FILES

Easy

91. Write a program to count the occurrences of a word in a text file.

92. Write code to count the number of lines in a text file.

93. Write a Python script to find and replace a word in a text file.

94. Write a program to merge two files into a third file

Medium

95. Write a Python program to count the number of words in a text file.

96. Write a Python script to find all files with a specific extension in a directory.

PACKAGE (USER DEFINED & BASIC PACKAGE)

Hard

97. Write code to find the Levenshtein distance between two strings.

98. Write a Python script to parse JSON data and extract specific information.

99. Write a program to import the sub-package projections from the matplotlib package
and alias it as mat.

100. Create a sub-package road with modules cars and bikes in the package transport.
Both modules must contain a function that prints a string of that module name. Also
create another python file to run the two functions.

You might also like