You are on page 1of 15

COMPUTER

PRACTICAL
NAME:-Anurag Roy

CLASS:-XII

SECTION:-M

ROLL NO.:-11
1) Write a program to take input of two lists from user and perform union and intersection
of these two lists. Example:
Enter first list: [2,3,5,6,7,8]
Enter second list: [4,5,6,9]
Union: [2,3,4,5,6,7,8,9]
Intersection: [5,6]
Answer:-

Output:-

2)Write a program to take input of a list from user and swap the adjacent elements (first &
second, Third & Forth and so on) Example:
Enter a list: [2,3,4,5,6,7,8]
Output: [3,2,5,4,7,6,8]
Answer:-
Output:-

3)Write a program to take input of a dictionary


Answer:-

Output:-

4) Write a program to take input of a dictionary where key is state and value is their capital.
Then sort the dictionary depending on key.
Example: Enter a dictionary:
{“WestBengal”:"Kolkata”,”Maharashtra":"Mumbai”,”Punjab":"chandhigar"}
Output: {“ Maharashtra":"Mumbai”,”Punjab":"chandhigar”, "WestBengal”:"Kolkata”," }
Answer:-

Output:-
5) Write a program to count number of word which is either “my” or “me” in a text file
“story.txt"
Answer:-

Output:-

6) Write a program to count and display the number of three letters word in a text file
"Hello.txt"
Answer:-

Output:-
7) Write a program to display the record of those employee (having field empid,
name,salary,age) from the binary file “employee.dat" whose name is starting with 'M'.
Answer:-

Output:-
8) Write a program to delete those record of employee (having field empid,
name,salary,age) from a binary file "employee.dat" whose salary is less than 55000
Answer:-
Output:-

9) Write a program to display the name of the patient by descending order of their age
from file “patient.csv which having 4 fields (id,name,age,city).
Answers:-
Output:-
10)Write a program to display the city of those patient whose name either starting with 'O’
or ending with 'r' and Age is more than 70 from file “patient.csv" which having 4 fields
(id,name,age,city).
Answer:-

Output:-
11. Write a program to take input of a list from user and perform the following operations:
(i) Display the second maximum number from the list. (ii) Display duplicate numbers from
the list. (iii) Display the highest frequency number with its frequency
from the list.

Answer:-

Output:-

12)Write a Python program to remove duplicate words from a given string and display the
resultant string in ascending order.
Original String: Next Time There Won't Be A Next Time
Output: A Be There Won't

Answer:-
Output:-

13) Write a Python program to display the frequency of each letter of an input string using
dictionary. Also display the number of vowels and consonants present in the given string.
Answer:-

Output:-
14) Write a program to take input of two dictionary from user and perform the following
operations:
(i) Display ad of two dictionaries.
(ii) Display difference of two dictionaries.

Answer:-

Output:-
15) Write a program to create a text file STORY.txt. Count and display the following:
a. Number of words in the file
b. Number of upper-case letters
c. Number of lower-case letters
d. Number of digits
e. Number of special characters

Answer:-

Output:-

You might also like