Python Programs
Pattern for Practical slips: (Total marks: 60) Marks distribution: 20+30+10
Program 1: 20 marks
Program 2: 30 marks
Viva: 10 marks
1. Write a program to check whether input number is divisible by 3 or 5 or both.
2. Write a program to read and display first and last n lines from a file.
3. Write a program which finds sum of digits of a number.
4. Write python program to find factorial of numbers using recursion.
5. Write a program to calculate the factorial of a number.
6. Write python program to find GCD of numbers using recursion.
7. Write a program which finds all factors of a number.
8. Write python program using an anonymous function to find area of circle,
circumference of circle.
9. Write a program to accept 5 numbers and calculate its Mean value.
10.Write python program which provides a hint to the user so that he can
figure out the correct alphabet. The program will ask the user to enter an
alphabet until they guess a stored alphabet correctly.
11.Write a program which reverses a string and displays both original and
reversed string.
12.Write python program to find factorial of numbers using recursion.
13.Write a program which accepts 10 integers and prints "DUPLICATES" if
any of the values entered are duplicates otherwise prints "ALL
UNIQUE".
14.Write a program to read a string from the user and append it into a file.
15.Write a program which prints fibonacci series of a number.
16.Write a program which reads a text file and counts the number of times a
certain letter appears in the text file.
17.Write a program which accepts an integer value 'n' and prints all
prime numbers till 'n'.
18.Write python program using an anonymous function to find area of circle,
circumference of circle.
19.Write a program to count the number of characters in a string.
20.Write a Python program to check if a given key already exists in a
dictionary. If key exists replace with another key/value pair.
21.Write a program to find the length of a set.
22.Write python program to accept and print string in reverse order using
recursion.
23.Write a program which finds sum of digits of a number.
24.Write a python program to accept NxN matrix and display the same.
25.Write a program to reverse a tuple.
26.Read a text file and print all the numbers present in the text file. Also
print the size of the file.
27.Write a program to find the repeated items of a tuple.
28.Write a Python program to accept n numbers in list and find maximum
and minimum from list.
29.Write a program to create a list of tuples with the first element as the
number and second element as the square of the number.
30.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}
31.Write a program to convert a tuple to a string.
32.Write a Python program to accept n numbers in list and remove
duplicates from a list.
33.Write a program which checks whether an element exists within a tuple.
34.Write a Python program to accept n numbers in list and find sum and
average of numbers in list.
35.Write a program to create set difference and a symmetric difference.
36.Write a Python program to accept n elements in a set and find the length
of a set, maximum, minimum value and the sum of values in a set.
37.Write a program to accept 10 numbers and find its median .
38.Write a Python program to create a tuple of n numbers and print
maximum, minimum, and sum of elements in a tuple.
39.Write a program to accept 10 numbers, display the sum of odd numbers
and sum of even numbers.
40.Write a program to create tuple of n numbers, print the first half values of
tuple in one line and the last half values of tuple on next line.
41.Write a program to accept a number 'n', and display the following pattern
(Floyd's triangle)n=3
1
23
456
42.Write a Python program to perform operation on sets which includes
union of two sets, an intersection of sets, set difference and a symmetric
difference.
43.Write a program to accept 10 numbers and find its Mode.
44.Write a Python program to accept two lists and merge the two lists into
list of tuple.
45.Write a program to accept a number and display its first ten multiples.
46.Write a Python program to accept a string and from a given string where
all occurrences of its first character have been changed to '$', except the
first char itself.
47.Write a program to display the following pattern.
1 2 3 4
1 2 3
1 2
1
48.Write a Python program to count frequency of each character in a given
string using user defined function.
49.Write a program to create list of tuples with the first element as the
number and second element as the cube of the number.
50.Write a Python program to count the occurrences of given word in
sentence. Accept sentence and word from user.
51.Write a program to check if an element exists within a tuple.
52.Write a Python program to accept string and remove the characters which
have odd index values of a given string using user defined function.
53.Write a program to accept and convert string in uppercase or vice versa.
54.Write a program to read the contents of a file in reverse order and display
the size of file.
55.Write a program to perform the add and remove operation on a set.
56.Write a program to count the number of blank spaces in a text file.
57. Write a program to get a single string from two given strings and swap the first two
characters of each string.
Sample String: 'abc', 'xyz'
Expected Output: xycabz
58.Write a program to read the contents of a file in reverse order and display
the size of file.
59.Write a python program which accept word and count the frequency
(occurrences) of given word in a file.
60. Write a program to create a union of sets.