0% found this document useful (0 votes)
2 views5 pages

Python Programs

The document outlines a comprehensive list of Python programming exercises categorized into various topics including basics, arrays, lists, matrices, strings, dictionaries, tuples, searching and sorting, date and time, printing patterns, and file handling. Each category contains multiple specific tasks aimed at enhancing programming skills in Python. This serves as a curriculum guide for M. Tech. students in the Department of CSE at the Institute of Management and Information Technology, Cuttack.
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)
2 views5 pages

Python Programs

The document outlines a comprehensive list of Python programming exercises categorized into various topics including basics, arrays, lists, matrices, strings, dictionaries, tuples, searching and sorting, date and time, printing patterns, and file handling. Each category contains multiple specific tasks aimed at enhancing programming skills in Python. This serves as a curriculum guide for M. Tech. students in the Department of CSE at the Institute of Management and Information Technology, Cuttack.
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

INSTITUTE OF MANAGEMENT AND INFORMATION TECHNOLOGY, CUTTACK

DEPARTMENT OF CSE
M. Tech. 1st Semester

PYTHON PROGRAMS
// Basics
1. Add two numbers
2. Maximum of two numbers
3. Factorial of a number
4. Find simple interest
5. Find compound interest
6. Check Armstrong Number
7. Find area of a circle
8. Print all Prime numbers in an Interval
9. Check whether a number is Prime or not
10. N-th Fibonacci number
11. Check if a given number is Fibonacci number?
12. Nth multiple of a number in Fibonacci Series
13. Print ASCII Value of a character
14. Sum of squares of first n natural numbers
15. Cube sum of first n natural numbers
// Array
16. Find sum of array
17. Find largest element in an array
18. Program for array rotation
19. Reversal algorithm for array rotation
20. Split the array and add the first part to the end
21. Find reminder of array multiplication divided by n
22. Check if given array is Monotonic
// List
23. Interchange first and last elements in a list
24. Swap two elements in a list
25. Ways to find length of list
26. Ways to check if element exists in list
27. Different ways to clear a list
28. Reversing a List
29. Find sum of elements in list
30. Multiply all numbers in the list
31. Find smallest number in a list
32. Find largest number in a list
33. Find second largest number in a list
34. Find N largest elements from a list
35. Even numbers in a list
36. Odd numbers in a List
37. Print all even numbers in a range
38. Print all odd numbers in a range
39. Print positive numbers in a list
40. Print negative numbers in a list
41. Print all positive numbers in a range
42. Print all negative numbers in a range
43. Remove multiple elements from a list
44. Remove empty List from List
45. Cloning or Copying a list
46. Count occurrences of an element in a list
47. Remove empty tuples from a list
48. Print duplicates from a list of integers
49. Find Cumulative sum of a list
50. Sum of number digits in List
51. Break a list into chunks of size N
52. Sort the values of first list using second list
// Matrix
53. Add two Matrices
54. Multiply two matrices
55. Matrix Product
56. Adding and Subtracting Matrices
57. Transpose a matrix in Single line
58. Matrix creation of n*n
59. Get Kth Column of Matrix
60. Vertical Concatenation in Matrix
// String
61. Check if a string is palindrome or not
62. Check whether the string is Symmetrical or Palindrome
63. Reverse words in a given String
64. Ways to remove i’th character from string
65. Check if a Substring is Present in a Given String
66. Words Frequency in String Shorthands
67. Convert Snake case to Pascal case
68. Find length of a string (4 ways)
69. Print even length words in a string
70. Accept the strings which contains all vowels
71. Count the Number of matching characters in a pair of string
72. Remove all duplicates from a given string
73. Least Frequent Character in String
74. Maximum frequency character in String
75. Check if a string contains any special character
76. Generating random strings until a given string is generated
77. Find words which are greater than given length k
78. Removing i-th character from a string
79. Split and join a string
80. Check if a given string is binary string or not
81. Find uncommon words from two Strings
82. Replace duplicate Occurrence in String
83. Replace multiple words with K
84. Permutation of a given string using inbuilt function
85. Check for URL in a String
86. Execute a String of Code
87. String slicing to rotate a string
88. String slicing to check if a string can become empty by recursive deletion
89. Counter| Find all duplicate characters in string
90. Replace all occurrences of a substring in a string
// Dictionary
91. Extract Unique values dictionary values
92. Find the sum of all items in a dictionary
93. Ways to remove a key from dictionary
94. Ways to sort list of dictionaries by values Using itemgetter
95. Ways to sort list of dictionaries by values Using lambda function
96. Merging two Dictionaries
97. Convert key-values list to flat dictionary
98. Insertion at the beginning in OrderedDict
99. Check order of character in string using OrderedDict( )
100. Dictionary and counter to find winner of election
101. Append Dictionary Keys and Values ( In order ) in dictionary
102. Sort Python Dictionaries by Key or Value
103. Sort Dictionary key and values List
104. Handling missing keys in Python dictionaries
105. Dictionary with keys having multiple inputs
106. Print anagrams together using List and Dictionary
107. K’th Non-repeating Character using List Comprehension and OrderedDict
108. Check if binary representations of two numbers are anagram
109. Counter to find the size of largest subset of anagram words
110. Remove all duplicates words from a given sentence
111. Dictionary to find mirror characters in a string
112. Counting the frequencies in a list using dictionary
113. Convert a list of Tuples into Dictionary
114. Counter and dictionary intersection example (Make a string using deletion and
rearrangement)
115. Dictionary, set and counter to check if frequencies can become same
116. Scraping And Finding Ordered Words In A Dictionary
117. Possible Words using given characters
118. Keys associated with Values in Dictionary
// Tuple
119. Find the size of a Tuple
120. Maximum and Minimum K elements in Tuple
121. Create a list of tuples from given list having number and its cube in each tuple
122. Adding Tuple to List and vice – versa
123. Closest Pair to Kth index element in Tuple
124. Join Tuples if similar initial element
125. Extract digits from Tuple list
126. All pair combinations of 2 tuples
127. Remove Tuples of Length K
128. Sort a list of tuples by second Item
129. Order Tuples using external List
130. Flatten tuple of List to tuple
131. Convert Nested Tuple to Custom Key Dictionary
// Searching and Sorting
132. Binary Search (Recursive and Iterative)
133. Linear Search
134. Insertion Sort
135. Recursive Insertion Sort
136. QuickSort
137. Iterative Quick Sort
138. Selection Sort
139. Bubble Sort
140. Merge Sort
141. Iterative Merge Sort
142. Heap Sort
143. Counting Sort
144. ShellSort
145. Topological Sorting
146. Radix Sort
147. Binary Insertion Sort
148. Bitonic Sort
149. Comb Sort
150. Pigeonhole Sort
151. Cocktail Sort
152. Gnome Sort
153. Odd-Even Sort / Brick Sort
154. BogoSort or Permutation Sort
155. Cycle Sort
156. Stooge Sort
// Date and Time
157. Get Current Time
158. Get Current Date and Time
159. Find yesterday’s, today’s and tomorrow’s date
160. Convert time from 12 hour to 24 hour format
161. Find difference between current time and given time
162. Create a Lap Timer
163. Convert date string to timestamp
164. Convert timestamp string to datetime object?
165. Find number of times every day occurs in a Year
// Printing Patterns
166. Print the pattern ‘G’
167. Print an Inverted Star Pattern
168. Print double sided stair-case pattern
169. Print with your own font
// File Handling in Python
170. Read file word by word
171. Read character by character from a file
172. Get number of characters, words, spaces and lines in a file
173. Count the Number of occurrences of a key-value pair in a text file
174. Finding ‘n’ Character Words in a Text File
175. Obtain the line number in which given word is present
176. Count number of lines in a text file
177. Remove lines starting with any prefix
178. Eliminate repeated lines from a file
179. Read List of Dictionaries from File
180. Append content of one text file to another
181. Copy odd lines of one file to other
182. Merge two files into a third file
183. Reverse a single line of a text file
184. Reverse the content of a file and store it in another file
185. Reverse the Content of a File using Stack

You might also like