Python Topics & Tasks Report
Python Topics & Tasks Report
Name:
Start Date: Batch:
Python
Introduction to Python Programming Language
Compiler/Interpreter
Difference between Explicit and Implicit Language
Variables in python
Data-types in Python
Operators in python
Input Output in python
Conditional Statements in python
Strings in python
Indexing in in python
Slicing in python
Strings Methods in python
Lists in python
Tuples in python
Difference between List and Tuple
Lists Slicing & Methods in python
Tuples Slicing & Methods in python
Dictionary in python
Dictionary Methods in python
Sets in python
Sets Methods in python
Difference Between Dictionary and set in python
Loops (for loop And While loop) in python
Functions in python
Recursion in python
File Input/Output(File Handling) in python
OOPS (Object-Oriented Programming) in python
Task Date Sign
Introduction to Python Programming Language.
Compiler/Interpreter.
Difference between Explicit and Implicit Language.
1. Print Hello Oscar
2. Print Home Address (using \t)
3. Print Student Information (using \n) (Name, Education, Birthdate)
4. Print OSCAR Word (cross - shape like X)
Variables in python
1. Print Assigned Value of Variable (2 int, 2 float, 2 char)
2. Print Value of Variable Entered by User (2 int, 2 float, 1 char)
3. Swap Two Number
Data-types in Python
Operators in python
1. Sum of Two Numbers
2. Subtraction of Two Numbers
3. Multiplication of Two Numbers
4. Division of Two Integer Numbers
5. Find Quotient and Remainder of Two Integer Numbers
6. Print Value of Equation (D = b*b - 4*a*c)
7. Find Area of Rectangle, Triangle & Circle
8. Voting System (Age is 18 or More Than)
9. Student Result (Marks is 35 or More Than)
10. Check Whether a Number is an Odd or Even
11. Check Whether a Character is an Alphabet or Not
12. Print a Number only if The Number is Between 1 to 100
13. Using All Assignment Operator Task
14. Floor of two integers number.
15. Using Increment and Decrement Operator Task (+=, -=, *=, /=, //==)
16. Bitwise operators task and difference between (or, |, and, &)
Input Output in python
1. Typecasting task (why it is necessary in python)
2. Basic input from user and output tasks.
Conditional Statements in python
1. Write a python program to take input of marks and display the division
obtained by the students. The marks obtained by a student in 5 different subject
are input through keyboard. The student gets a division as per the following
rules:
Percentage above or equal to 60 -> First Division
Percentage between 50 and 59 -> Second Division
Percentage between 40 and 49 -> Third Division
Percentage less than 40 -> Fail
2. Write a python program to find out the payment made to the employee. The
workers in a factory are paid according to the following rules. Their regular
working hours are 40, for which they are paid at the rate of Rs. 2.50 per hour.
If overtime hours are between 1 & 5 -> Rs. 7.00 per hour
If overtime hours are between 6 & 10 -> Rs. 8.50 per hour
If overtime hours are above 10 -> Rs. 12.00 per hour
3. A mathematics student has three equations as follows. Values of a, b, c & y are
entered by user. Write a python Program to evaluate k.
z+c = a^2+2ab
2ac = b^2-x-2z
y = z+5x-2yb+k
4. Check Whether a Number is Positive or Negative or Zero.
5. Find the Largest Number among Three Numbers
6. Check an Alphabet is Vowel or Consonant
7. Check Whether the Entered Year is Leap Year or not
Strings in python
Indexing in python
Slicing in python
Strings Methods in python
All questions for string (including slicing, indexing and methods):-
1. Write a Python program to calculate the length of a string.
2. Write a Python program to count the number of characters (character
frequency) in a string.
Sample String: 'google.com'
Expected Result: {'g': 2, 'o': 3, 'l': 1, 'e': 1, '.': 1, 'c': 1, 'm': 1}
3. Write a Python program to get a string made of the first 2 and last 2 characters
of a given string. If the string length is less than 2, return the empty string
instead.
Sample String: 'w3resource'
Expected Result: 'w3ce'
Sample String: 'w3'
Expected Result: 'w3w3'
Sample String: 'w'
Expected Result: Empty String
4. Write a Python program to get a string from a given string where all
occurrences of its first char have been changed to '$', except the first char itself.
Sample String: 'restart'
Expected Result: 'resta$t'
5. Write a Python program to get a single string from two given strings, separated
by a space and swap the first two characters of each string.
Sample String: 'abc', 'xyz'
Expected Result: 'xyc abz'
6. 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', add 'ly' instead. If the
string length of the given string is less than 3, leave it unchanged.
Sample String: 'abc'
Expected Result: 'abcing'
Sample String: 'string'
Expected Result: 'stringly'
7. Write a Python program to find the first appearance of the substrings 'not' and
'poor' in a given string. If 'not' follows 'poor', replace the whole 'not'...'poor'
substring with 'good'. Return the resulting string.
Sample String: 'The lyrics is not that poor!''The lyrics is poor!'
Expected Result: 'The lyrics is good!''The lyrics is poor!'
8. Write a Python function that takes a list of words and return the longest word
and the length of the longest one.
9. Write a Python program to remove the nth index character from a nonempty
string.
10. Write a Python program to change a given string to a newly string where the
first and last chars have been exchanged.
11. Write a Python program to remove characters that have odd index values in a
given string.
12. Write a Python program to count the occurrences of each word in a given
sentence.
13. Write a Python script that takes input from the user and displays that input
back in upper and lower cases.
14. Write a Python program that accepts a comma-separated sequence of words
as input and prints the distinct words in sorted form (alphanumerically).
Sample Words: red, white, black, red, green, black
Expected Result: black, green, red, white,red
15. Write a Python function to create an HTML string with tags around the
word(s).
Sample function and result: add_tags('i', 'Python') -> '<i>Python</i>'add_tags('b',
'Python Tutorial') -> '<b>Python Tutorial </b>'
16. Write a Python function to insert a string in the middle of a string.
Sample function and result: insert_sting_middle('[[]]<<>>', 'Python') ->
[[Python]]insert_sting_middle('{{}}', 'PHP') -> {{PHP}}
17. Write a Python function to get a string made of 4 copies of the last two
characters of a specified string (length must be at least 2).
Sample function and result: insert_end('Python') ->
ononononinsert_end('Exercises') -> eseseses
18. Write a Python function to get a string made of the first three characters of a
specified string. If the length of the string is less than 3, return the original string.
Sample function and result: first_three('ipy') -> ipyfirst_three('python') -> pyt
19. Write a Python program to get the last part of a string before a specified
character.https://www.w3resource.com/python-
exerciseshttps://www.w3resource.com/python
20. Write a Python function to reverse a string if its length is a multiple of 4.
21. Write a Python function to convert a given string to all uppercase if it contains
at least 2 uppercase characters in the first 4 characters.
22. Write a Python program to sort a string lexicographically.
23. Write a Python program to remove a newline in Python.
24. Write a Python program to check whether a string starts with specified
characters.
25. Write a Python program to create a Caesar encryption.
Notes:- In cryptography, a Caesar cipher, also known as Caesar's cipher, the shift
cipher, Caesar's code or Caesar shift, is one of the simplest and most widely
known encryption techniques. It is a type of substitution cipher in which each
letter in the plaintext is replaced by a letter some fixed number of positions down
the alphabet. For example, with a left shift of 3, D would be replaced by A, E
would become B, and so on. The method is named after Julius Caesar, who used
it in his private correspondence.
26. Write a Python program to display formatted text (width=50) as output.
27. Write a Python program to remove existing indentation from all of the lines in
a given text.
28. Write a Python program to add prefix text to all of the lines in a string.
29. Write a Python program to set the indentation of the first line.
30. Write a Python program to print the following numbers up to 2 decimal
places.
31. Write a Python program to print the following numbers up to 2 decimal
places with a sign.
32. Write a Python program to print the following positive and negative numbers
with no decimal places.
33. Write a Python program to print the following integers with zeros to the left
of the specified width.
34. Write a Python program to print the following integers with '*' to the right of
the specified width.
35. Write a Python program to display a number with a comma separator.
36. Write a Python program to format a number with a percentage.
37. Write a Python program to display a number in left, right, and center aligned
with a width of 10.
38. Write a Python program to count occurrences of a substring in a string.
39. Write a Python program to reverse a string.
40. Write a Python program to reverse words in a string.
Lists in python
Lists Slicing & Methods in python
All questions regarding (list, slicing and method):-
1. Write a Python program to sum all the items in a list.
2. Write a Python program to multiply all the items in a list.
3. Write a Python program to get the largest number from a list.
4. Write a Python program to get the smallest number from a list.
5. Write a Python program to count the number of strings from a given list of
strings. The string length is 2 or more and the first and last characters are the
same.
Sample List: ['abc', 'xyz', 'aba', '1221']
Expected Result: 2
6. Write a Python program to get a list, sorted in increasing order by the last
element in each tuple from a given list of non-empty tuples.
Sample List: [(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)]
Expected Result: [(2, 1), (1, 2), (2, 3), (4, 4), (2, 5)]
7. Write a Python program to remove duplicates from a list.
8. Write a Python program to check if a list is empty or not.
9. Write a Python program to clone or copy a list.
10. Write a Python program to find the list of words that are longer than n from a
given list of words.
11. Write a Python function that takes two lists and returns true if they have at
least one common member.
12. Write a Python program to print a specified list after removing the 0th, 4th
and 5th elements.
Sample List: ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow']Expected Output :
['Green', 'White', 'Black']
13. Write a Python program to generate a 3*4*6 3D array whose each element is
*.
14. Write a Python program to print the numbers of a specified list after
removing even numbers from it.
15. Write a Python program to shuffle and print a specified list.
16. Write a Python program to generate and print a list of the first and last 5
elements where the values are square numbers between 1 and 30 (both
included).
17. Write a Python program to check if each number is prime in a given list of
numbers. Return True if all numbers are prime otherwise False.
Sample Data: ([0, 3, 4, 7, 9]) -> False([3, 5, 7, 13]) -> True([1, 5, 3]) -> False
18. Write a Python program to generate all permutations of a list in Python.
19. Write a Python program to calculate the difference between the two lists.
20. Write a Python program to access the index of a list.
21. Write a Python program to convert a list of characters into a string.
22. Write a Python program to find the index of an item in a specified list.
23. Write a Python program to flatten a shallow list.
24. Write a Python program to append a list to the second list.
25. Write a Python program to select an item randomly from a list.
26. Write a Python program to check whether two lists are circularly identical.
27. Write a Python program to find the second smallest number in a list.
28. Write a Python program to find the second largest number in a list.
29. Write a Python program to get unique values from a list.
30. Write a Python program to get the frequency of elements in a list.
31. Write a Python program to count the number of elements in a list within a
specified range.
32. Write a Python program to check whether a list contains a sublist.
33. Write a Python program to generate all sublists of a list.
34. Write a Python program that uses the Sieve of Eratosthenes method to
compute prime numbers up to a specified number.
Notes:- In mathematics, the sieve of Eratosthenes, (Ancient Greek: κόσκινον
Ἐρατοσθένους, kóskinon Eratosthénous) one of a number of prime number
sieves, is a simple, ancient algorithm for finding all prime numbers up to any
given limit.
35. Write a Python program to create a list by concatenating a given list with a
range from 1 to n.
Sample list: ['p', 'q']n =5Sample Output : ['p1', 'q1', 'p2', 'q2', 'p3', 'q3', 'p4', 'q4',
'p5', 'q5']
36. Write a Python program to get a variable with an identification number or
string.
37. Write a Python program to find common items in two lists.
38. Write a Python program to change the position of every n-th value to the
(n+1)th in a list.
Sample list: [0,1,2,3,4,5]Expected Output: [1, 0, 3, 2, 5, 4]
39. Write a Python program to convert a list of multiple integers into a single
integer.
Sample list: [11, 33, 50]
Expected Output: 113350
40. Write a Python program to split a list based on the first character of a word.
Tuples in python
Tuples Slicing & Methods in python
All questions of tuple (slicing and methods):-
1. Write a Python program to create a tuple.
2. Write a Python program to create a tuple with different data types.
3. Write a Python program to create a tuple of numbers and print one item.
4. Write a Python program to unpack a tuple into several variables.
5. Write a Python program to add an item to a tuple.
6. Write a Python program to convert a tuple to a string.
7. Write a Python program to get the 4th element from the last element of a
tuple.
8. Write a Python program to create the colon of a tuple.
9. Write a Python program to find repeated items in a tuple.
10. Write a Python program to check whether an element exists within a tuple.
11. Write a Python program to convert a list to a tuple.
12. Write a Python program to remove an item from a tuple.
13. Write a Python program to slice a tuple.
14. Write a Python program to find the index of an item in a tuple.
15. Write a Python program to find the length of a tuple.
16. Write a Python program to convert a tuple to a dictionary.
17. Write a Python program to unzip a list of tuples into individual lists.
18. Write a Python program to reverse a tuple.
19. Write a Python program to convert a list of tuples into a dictionary.
20. Write a Python program to print a tuple with string formatting.
Sample tuple: (100, 200, 300)
Output: This is a tuple (100, 200, 300)
21. Write a Python program to replace the last value of tuples in a list.
Sample list: [(10, 20, 40), (40, 50, 60), (70, 80, 90)]
Expected Output: [(10, 20, 100), (40, 50, 100), (70, 80, 100)]
22. Write a Python program to remove an empty tuple(s) from a list of tuples.
Sample data: [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')]
Expected output: [('',), ('a', 'b'), ('a', 'b', 'c'), 'd']
23. Write a Python program to sort a tuple by its float element.
Sample data: [('item1', '12.20'), ('item2', '15.10'), ('item3', '24.5')]
Expected Output: [('item3', '24.5'), ('item2', '15.10'), ('item1', '12.20')]
24. Write a Python program to count the elements in a list until an element is a
tuple.
25. Write a Python program to convert a given string list to a tuple.
Original string: python 3.0
<class 'str'>
Convert the said string to a tuple:
('p', 'y', 't', 'h', 'o', 'n', '3', '.', '0')
<class 'tuple'>
26. Write a Python program to calculate the product, multiplying all the numbers
in a given tuple.
Original Tuple:
(4, 3, 2, 2, -1, 18)
Product - multiplying all the numbers of the said tuple: -864
Original Tuple:
(2, 4, 8, 8, 3, 2, 9)
Product - multiplying all the numbers of the said tuple: 27648
27. Write a Python program to calculate the average value of the numbers in a
given tuple of tuples.
Original Tuple:
((10, 10, 10, 12), (30, 45, 56, 45), (81, 80, 39, 32), (1, 2, 3, 4))
Average value of the numbers of the said tuple of tuples:
[30.5, 34.25, 27.0, 23.25]
Original Tuple:
((1, 1, -5), (30, -15, 56), (81, -60, -39), (-10, 2, 3))
Average value of the numbers of the said tuple of tuples:
[25.5, -18.0, 3.75]
28. Write a Python program to convert a tuple of string values to a tuple of
integer values.
Original tuple values:
(('333', '33'), ('1416', '55'))
New tuple values:
((333, 33), (1416, 55))
29. Write a Python program to convert a given tuple of positive integers into an
integer.
Original tuple:
(1, 2, 3)
Convert the said tuple of positive integers into an integer:
123
Original tuple:
(10, 20, 40, 5, 70)
Convert the said tuple of positive integers into an integer:
102040570
30. Write a Python program to check if a specified element appears in a tuple of
tuples.
Original list:
(('Red', 'White', 'Blue'), ('Green', 'Pink', 'Purple'), ('Orange', 'Yellow', 'Lime'))
Check if White presenet in said tuple of tuples!
True
Check if White presenet in said tuple of tuples!
True
Check if Olive presenet in said tuple of tuples!
False
31. Write a Python program to compute the element-wise sum of given tuples.
Original lists:
(1, 2, 3, 4)
(3, 5, 2, 1)
(2, 2, 3, 1)
Element-wise sum of the said tuples:
(6, 9, 8, 6)
32. Write a Python program to compute the sum of all the elements of each tuple
stored inside a list of tuples.
Original list of tuples:
[(1, 2), (2, 3), (3, 4)]
Sum of all the elements of each tuple stored inside the said list of tuples:
[3, 5, 7]
Original list of tuples:
[(1, 2, 6), (2, 3, -6), (3, 4), (2, 2, 2, 2)]
Sum of all the elements of each tuple stored inside the said list of tuples:
[9, -1, 7, 8]
33. Write a Python program to convert a given list of tuples to a list of lists.
Original list of tuples: [(1, 2), (2, 3), (3, 4)]
Convert the said list of tuples to a list of lists: [[1, 2], [2, 3], [3, 4]]
Original list of tuples: [(1, 2), (2, 3, 5), (3, 4), (2, 3, 4, 2)]
Convert the said list of tuples to a list of lists: [[1, 2], [2, 3, 5], [3, 4], [2, 3, 4, 2]]
Difference between List and Tuple
Dictionary in python
Dictionary Methods in python
All questions dictionary:-
1. Write a Python script to sort (ascending and descending) a dictionary by value.
2. Write a Python script to add a key to a dictionary.
Sample Dictionary: {0: 10, 1: 20}
Expected Result: {0: 10, 1: 20, 2: 30}
3. Write a Python script to concatenate the following dictionaries to create a new
one.
Sample Dictionary:
dic1 = {1:10, 2:20}
dic2 = {3:30, 4:40}
dic3 = {5:50, 6:60}
Expected Result: {1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60}
4. Write a Python script to check whether a given key already exists in a
dictionary.
5. Write a Python program to iterate over dictionaries using for loops.
6. Write a Python script to generate and print a dictionary that contains a
number (between 1 and n) in the form (x, x*x).
Sample Dictionary (n = 5):
Expected Output: {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
7. Write a Python script to print a dictionary where the keys are numbers
between 1 and 15 (both included) and the values are the square of the keys.
Sample Dictionary
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81, 10: 100, 11: 121, 12: 144,
13: 169, 14: 196, 15: 225}
8. Write a Python script to merge two Python dictionaries.
9. Write a Python program to iterate over dictionaries using for loops.
10. Write a Python program to sum all the items in a dictionary.
11. Write a Python program to multiply all the items in a dictionary.
12. Write a Python program to remove a key from a dictionary.
13. Write a Python program to map two lists into a dictionary.
14. Write a Python program to sort a given dictionary by key.
15. Write a Python program to get the maximum and minimum values of a
dictionary.
16. Write a Python program to get a dictionary from an object's fields.
17. Write a Python program to remove duplicates from the dictionary.
18. Write a Python program to check if a dictionary is empty or not.
19. Write a Python program to combine two dictionary by adding values for
common keys.
d1 = {'a': 100, 'b': 200, 'c':300}
d2 = {'a': 300, 'b': 200, 'd':400}
Sample output: Counter({'a': 400, 'b': 400, 'd': 400, 'c': 300})
20. Write a Python program to print all distinct values in a dictionary.
Sample Data: [{"V":"S001"}, {"V": "S002"}, {"VI": "S001"}, {"VI": "S005"},
{"VII":"S005"}, {"V":"S009"}, {"VIII":"S007"}]
Expected Output: Unique Values: {'S005', 'S002', 'S007', 'S001', 'S009'}
21. Write a Python program to create and display all combinations of letters,
selecting each letter from a different key in a dictionary.
Sample data: {'1':['a','b'], '2':['c','d']}
Expected Output:
ac
ad
bc
bd
22. Write a Python program to find the highest 3 values of corresponding keys in
a dictionary.
23. Write a Python program to combine values in a list of dictionaries.
Sample data: [{'item': 'item1', 'amount': 400}, {'item': 'item2', 'amount': 300},
{'item': 'item1', 'amount': 750}]
Expected Output: Counter({'item1': 1150, 'item2': 300})
24. Write a Python program to create a dictionary from a string.
Note: Track the count of the letters from the string.
Sample string: 'w3resource'
Expected output: {'w': 1, '3': 1, 'r': 2, 'e': 2, 's': 1, 'o': 1, 'u': 1, 'c': 1}
25. Write a Python program to print a dictionary in table format.
26. Write a Python program to count the values associated with a key in a
dictionary.
Expected Output:
6
2
27. Write a Python program to convert a list into a nested dictionary of keys.
28. Write a Python program to sort a list alphabetically in a dictionary.
29. Write a Python program to remove spaces from dictionary keys.
30. Write a Python program to get the top three items in a shop.
Sample data: {'item1': 45.50, 'item2':35, 'item3': 41.30, 'item4':55, 'item5': 24}
Expected Output:
item4 55
item1 45.5
item3 41.3
Sets in python
Sets Methods in python
All questions set:-
1. Write a Python program to create a set.
2. Write a Python program to iterate over sets.
3. Write a Python program to add member(s) to a set.
4. Write a Python program to remove item(s) from a given set.
5. Write a Python program to remove an item from a set if it is present in the set.
6. Write a Python program to create an intersection of sets.
7. Write a Python program to create a union of sets.
8. Write a Python program to create set difference.
9. Write a Python program to create a symmetric difference.
10. Write a Python program to check if a set is a subset of another set.
11. Write a Python program to create a shallow copy of sets.
Notes:- Shallow copy is a bit-wise copy of an object. A new object is created that
has an exact copy of the values in the original object.
12. Write a Python program to remove all elements from a given set.
13. Write a Python program that uses frozensets.
Notes:- Frozensets behave just like sets except they are immutable.
14. Write a Python program to find the maximum and minimum values in a set.
15. Write a Python program to find the length of a set.
16. Write a Python program to check if a given value is present in a set or not.
17. Write a Python program to check if two given sets have no elements in
common.
18. Write a Python program to check if a given set is a superset of itself and a
superset of another given set.
19. Write a Python program to find elements in a given set that are not in
another set.
20. Write a Python program to remove the intersection of a second set with a
first set.
21. Write a Python program to find all the unique words and count the frequency
of occurrence from a given list of strings. Use Python set data type.
22. Write a Python program that finds all pairs of elements in a list whose sum is
equal to a given value.
23. Write a Python program to find the longest common prefix of all strings. Use
the Python set.
24. Write a Python program to find the two numbers whose product is maximum
among all the pairs in a given list of numbers. Use the Python set.
25. Given two sets of numbers, write a Python program to find the missing
numbers in the second set as compared to the first and vice versa. Use the
Python set.
26. Write a Python program to find all the anagrams and group them together
from a given list of strings. Use the Python data type.
27. Write a Python program to find all the anagrams in a given list of strings and
then group them together. Use the Python data type.
28. Write a Python program to find all the unique combinations of 3 numbers
from a given list of numbers, adding up to a target number.
29. Write a Python program to find the third largest number from a given list of
numbers. Use the Python set data type.
30. Write a Python program to remove all duplicates from a given list of strings
and return a list of unique strings. Use the Python set data type.
Difference between Dictionary and set in python
Loops (for loop And While loop) in python
1. Write a python Program to check whether a given number is prime or not.
2. Write a python program to print factorial of a positive integer N.
3. Write a python program to perform division without using division operator.
4. Write a python program to print factors of a given positive integer.
5. Write a python program to check whether a given number is Armstrong
number or not
6. Write a python program to Count Number of digits in an Integer
7. Write a python Program to read an integer and display its multiplication table.
8. Write a python program to print all prime numbers up to N.
9. Write a python Program to print all Armstrong numbers upto N.
10. Write a python program to print all upper case alphabets.
11. Write a python program to print sum of all odd numbers up to N.
12. Write a python program to print sum of all odd digits present in the number.
For e.g N = 12583
Sum = 1+5+3=9
13. Write a python program to print Fibonacci series upto N.
Functions in python
1. Sum of Two Numbers
2. Multiplication Table
3. Find Area of Rectangle Using Function
4. Check Whether a Number is Even or Odd Using Function
5. Check Whether a Number is Prime or Not Using Function
Recursion in python
1. Find the Sum of Natural Numbers Using Recursion
2. Calculate the Factorial of a Number Using Recursion
File Input / Output (File Handling) in python
1. Write a Python program to read an entire text file.
2. Write a Python program to read first n lines of a file.
3. Write a Python program to append text to a file and display the text.
4. Write a Python program to read last n lines of a file.
5. Write a Python program to read a file line by line and store it into a list.
6. Write a Python program to read a file line by line store it into a variable.
7. Write a Python program to read a file line by line store it into an array.
8. Write a python program to find the longest words.
9. Write a Python program to count the number of lines in a text file.
10. Write a Python program to count the frequency of words in a file.
11. Write a Python program to get the file size of a plain file.
12. Write a Python program to write a list to a file.
13. Write a Python program to copy the contents of a file to another file.
14. Write a Python program to combine each line from first file with the
corresponding line in second file.
15. Write a Python program to read a random line from a file.
16. Write a Python program to assess if a file is closed or not.
17. Write a Python program to remove newline characters from a file.
18. Write a Python program that takes a text file as input and returns the number
of words of a given text file.
Notes:- Some words can be separated by a comma with no space.
19. Write a Python program to extract characters from various text files and puts
them into a list.
20. Write a Python program to generate 26 text files named A.txt, B.txt, and so
on up to Z.txt.
21. Write a Python program to create a file where all letters of English alphabet
are listed by specified number of letters on each line.
OOPS (Object-Oriented Programming) in python
1. Write a Python program to create a class representing a Circle. Include
methods to calculate its area and perimeter.
2. Write a Python program to create a person class. Include attributes like name,
country and date of birth. Implement a method to determine the person's age.
3. Write a Python program to create a calculator class. Include methods for basic
arithmetic operations.
4. Write a Python program to create a class that represents a shape. Include
methods to calculate its area and perimeter. Implement subclasses for different
shapes like circle, triangle, and square.
5. Write a Python program to create a class representing a binary search tree.
Include methods for inserting and searching for elements in the binary tree.
6. Write a Python program to create a class representing a stack data structure.
Include methods for pushing and popping elements.
7. Write a Python program to create a class representing a linked list data
structure. Include methods for displaying linked list data, inserting and deleting
nodes.
8. Write a Python program to create a class representing a shopping cart. Include
methods for adding and removing items, and calculating the total price.
9. Write a Python program to create a class representing a stack data structure.
Include methods for pushing, popping and displaying elements.
10. Write a Python program to create a class representing a queue data
structure. Include methods for enqueueing and dequeueing elements.
11. Write a Python program to create a class representing a bank. Include
methods for managing customer accounts and transactions.
Project:- Game Using Python Basics and OOPS.