Python Programs_Autonomus_4
Python Programs_Autonomus_4
Pattern for Practical slips: (Total marks: 60) Marks distribution: 20+30+10
Program 1: 20 marks
Program 2: 30 marks
Viva: 10 marks
2. Write a program to read and display first and last n lines from a file.
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.
14.Write a program to read a string from the user and append it into a file.
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'.
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.
26.Read a text file and print all the numbers present in the text file. Also
print the size of the file.
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.
Sample Dictionary (n = 5)
Expected Output : {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
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.
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
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.
1 2 3 4
1 2 3
1 2
1
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.
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.
57. Write a program to get a single string from two given strings and swap the first two
characters of each string.
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.