List of Python Programs
List of Python Programs
Conditional statement
35. Write a program to Accept two Integers and Check if they are Equal.
36. Write a program to Check if a given Integer is Positive or Negative and Odd or Even.
37. Write a program to Check if a given Integer is Divisible by 7 or not.
38. Write a program to find the greatest of three numbers using else if ladder.
39. Write a program to find the greatest of three numbers using Nested if.
40. Write a program to convert an Upper-case character into lower case and vice-versa.
41. Write a program to check weather an entered year is leap year or not.
42. Write a Program to check whether an alphabet entered by the user is a vowel or a constant.
43. Write a program to Read a Coordinate Point and Determine its Quadrant.
44. Write a program to Add two Complex Numbers.
45. Write a Program to find roots of a quadratic expression.
46. Write a program to print day according to the day number entered by the user.
47. Write a program to print color name, if user enters the first letter of the color name.
48. Write a program to Simulate Arithmetic Calculator.
49. Write a menu driven program for calculating area of different geometrical figures such as circle,
square, rectangle, and triangle.
50. WAP that accepts the marks of 5 subjects and finds the percentage marks obtained by the student. It
also prints grades according to the following criteria: Between 90-100% Print 'A', 80-90% Print 'B', 60-
80% Print 'C', 50-60% Print 'D', 40-50% Print 'E', Below 40% Print 'F’.
51. WAP to enter a character and then determine whether it is a vowel, consonants, or a digit.
LOOPS:
52. Write a program to display all even numbers from 1 to 20
53. Write a program to print all the Numbers Divisible by 7 from 1 to 100.
54. Write a program to print table of any number.
55. Write a program to print 1,2,3,5,6,7,8,9 use continue statement.
56. Write a program to print table of 5 in following format.
5X1=5
5 X 2 = 10
5 X 3 = 15
57. Write a program to Find the Sum of first 50 Natural Numbers using for Loop.
58. Write a program to calculate factorial of a given number using for loop and also using while loop.
59. Write a program to count the sum of digits in the entered number.
60. Write a program to find the reverse of a given number.
61. Write a program to Check whether a given Number is Perfect Number.
62. Write a program to check if the given number is a Disarium Number (11+ 72 + 53 = 1+ 49 + 125 = 175).
63. Write a program to determine whether the given number is a Harshad Number (If a number is divisible
by the sum of its digits, then it will be known as a Harshad Number).
64. Write a program to Print Armstrong Number from 1 to 1000.
65. Write a program to Compute the Value of Xn.
66. Write a program to Calculate the value of nCr.
67. Write a program to generate the Fibonacci Series.
68. Write a program to check whether a given Number is Palindrome or Not.
69. Write a program to Check whether a given Number is an Armstrong Number.
70. Write a program to check weather a given number is prime number or not.
71. Write a program to print all prime numbers from 1-500.
72. Write a program to find the Sum of all prime numbers from 1-1000.
73. Write a program to display the following pattern:
*****
*****
*****
*****
*****
74. Write a program to display the following pattern:
*
**
***
****
*****
75. Write a program to display the following pattern:
1
12
123
1234
12345
76. Write a program to display the following pattern:
1
22
333
4444
55555
Functions
127. Write a Python function to find the Max of three numbers.
128. Write a Python function to sum all the numbers in a list.
Sample List : (8, 2, 3, 0, 7)
Expected Output : 20
129. Write a Python function to multiply all the numbers in a list.
Sample List : (8, 2, 3, -1, 7)
Expected Output : -336
130. Write a Python program to reverse a string.
Sample String : "1234abcd"
Expected Output : "dcba4321"
131. Write a Python program calculate the factorial of a number using lambda and reduce functions. The
function accepts the number as an argument.
132. Write a Python function to check whether a number falls in a given range.
133. Write a Python function that accepts a string and calculate the number of upper-case letters and
lower-case letters.
Sample String: 'The quick Brow Fox'
Expected Output :
No. of Upper case characters : 3
No. of Lower case Characters : 12
134. Write a Python function that takes a list and returns a new list with unique elements of the first list.
Sample List : [1,2,3,3,3,3,4,5]
Unique List : [1, 2, 3, 4, 5]
135. Write a Python function that takes a number as a parameter and check the number is prime or not.
136. Write a Python function that checks whether a passed string is palindrome or not.
137. Write a Python function that prints out the first n rows of Pascal's triangle.
138. Write a Python function to check whether a string is a pangram or not.
Note: Pangrams are words or sentences containing every letter of the alphabet at least once.
For example: "The quick brown fox jumps over the lazy dog"
139. Write a Python function that accepts a hyphen-separated sequence of words as input and prints the
words in a hyphen-separated sequence after sorting them alphabetically.
Sample Items: green-red-yellow-black-white
Expected Result: black-green-red-white-yellow
140. Python function to convert height (in feet and inches) to centimeters.
141. Python function to Convert Celsius to Fahrenheit.
142. Python function to display all the Armstrong number from 1 to n.
Recursion:
143. Write a program using recursion to compute factorial of a given number.
144. Write a program to print Fibonacci Series using recursion.
145. Write a program to calculate sum of numbers 1 to N using recursion.
146. Write a program to Find Sum of Digits of the Number using Recursive Function.
147. Write a program to print Tower of Hanoi using recursion.
148. Python Program to Determine How Many Times a Given Letter Occurs in a String Recursively
149. Python Program to Find the Binary Equivalent of a Number Recursively
150. Python Program to Find the GCD of Two Numbers Using Recursion
151. Python Program to Find if a Number is Prime or Not Prime Using Recursion
152. Python Program to Find the Power of a Number Using Recursion
153. Python Program to Check Whether a String is a Palindrome or not Using Recursion
154. Python Program to Reverse a String Using Recursion.
155. WAP to convert a list of string type numbers into list of integer type numbers using map function.
Ex: Input: [‘45’,’88’,’9’] Output:[45,88,9]
156. WAP to find the largest element in the list using reduce function.
157. WAP to compute the cube of all numbers in the given list using map() function.
158. WAP to multiply two numbers using lambda function.
159. WAP to create a new list consisting of odd numbers from the given list of numbers using filter()
function.
160. WAP to compute the sum of all the elements of the list using reduce() function.
String:
161. Python program to check whether the string is Symmetrical or Palindrome
162. Ways to remove i’th character from string in Python
163. Python program to Check if a Substring is Present in a Given String
164. Find length of a string in python (4 ways)
165. Python program to print even length words in a string
166. Python program to accept the strings which contains all vowels
167. Remove all duplicates from a given string in Python
168. Python program to Maximum frequency character in String
169. Python Program to check if a string contains any special character
170. Find words in string which are greater than given length k
171. Python program to split and join a string
172. Python program to Replace duplicate Occurrence in String
173. Python program to Check for URL in a String
174. Python program to find all duplicate characters in string
175. Python Program to Replace all Occurrences of ‘a’ with $ in a String
176. Python Program to Form a New String where the First Character and the Last Character have been
Exchanged
177. Python Program to Count the Number of Vowels in a String
178. Python Program to Take in a String and Replace Every Blank Space with Hyphen
179. Python Program to Calculate the Length of a String Without Using a Library Function
180. Python Program to Remove the Characters of Odd Index Values in a String
181. Python Program to Calculate the Number of Words and the Number of Characters Present in a String
182. Python Program to Take in Two Strings and Display the Larger String without Using Built-in Functions
183. Python Program to Check if a String is a Pangram or Not
(A pangram is a sentence that uses all 26 letters of the English alphabet at least once. like” The quick brown fox
jumps over the lazy dog”)
184. Python Program to Accept a Hyphen Separated Sequence of Words as Input and Print the Words in a
Hyphen-Separated Sequence after Sorting them Alphabetically
185. Python Program to Form a New String Made of the First 2 and Last 2 characters From a Given String
186. Python Program to Count the Occurrences of Each character in a Given String Sentence
187. Python Program to Check if a Substring is Present in a Given String
188. Python Program to Print All Permutations of a String in Lexicographic Order without Recursion
189. Python Program to Find the Most Repeated Word in a String.
LIST
190. Program to interchange first and last elements in a list
191. WAP to find min, max and average of elements of a list having numeric data
192. Program to check if element exists in list
193. Program for Reversing a List
194. Program to Multiply all numbers in the list
195. Program to find smallest and largest number in a list
196. Program to find second largest number in a list
197. Program to print all even numbers in a range
198. Program to print all negative numbers in a range
199. Program to Remove multiple elements from a list in Python
200. Program to Cloning or Copying a list
201. Program to Count occurrences of an element in a list
202. Program to find Cumulative sum of a list
203. Program to Break a list into chunks of size N in Python
204. Python Program to transpose of Matrix.
205. Python Program to Add Two Matrices.
206. Python Program to Multiply Two Matrices.
207. Program to get Kth Column of Matrix
208. WAP to print all even numbers of a list using list comprehension.
209. WAP that prompts user to enter an alphabet and then print all the words that starts with that alphabet
from the list of words.
210. WAP to transpose a given matrix using list comprehension.
Tuple:
Set:
216. Python Program to Count the Number of Vowels Present in a String using Sets
217. Python Program to Check Common Letters in Two Input Strings
218. Python Program that Displays which Letters are in the First String but not in the Second
219. Python Program that Displays which Letters are Present in Both the Strings
220. Python Program that Displays which Letters are in the Two Strings but not in Both
221. Write a program that generates a set of prime numbers and another set of odd numbers. Demonstrate
the result of union, intersection, difference and symmetric difference operations on these sets.
Dictionary:
222. Python Program to Add a Key-Value Pair to the Dictionary
223. Python Program to Concatenate Two Dictionaries into One.
224. Python Program to Check if a Given Key Exists in a Dictionary or Not
225. Python Program to Generate a Dictionary that Contains Numbers (between 1 and n) in the Form
(x,x*x).
226. Python program to create an instance of an Ordered dict using a given dictionary. Sort the dictionary
during the creation and print the members of the dictionary in reverse order.
227. Python Program to Sum All the Items in a Dictionary
228. WAP to create dictionary which has characters of given string as keys and frequency of characters as
values.
229. Python Program to Multiply All the Items in a Dictionary
230. Python Program to Remove the Given Key from a Dictionary
231. Python Program to Form a Dictionary from an Object of a Class
232. Python Program to Map Two Lists into a Dictionary
233. Python Program to Count the Frequency of Words Appearing in a String Using a Dictionary
234. Python Program to Create a Dictionary with Key as First Character and Value as Words Starting with
that Character