Aadi Singh Python Practical File 24-25
Aadi Singh Python Practical File 24-25
(Session 2024-25)
SUBMITTED TO SUBMITTED BY
MR.MOHIT DUBEY KANISHTH
KATIYAR
12-B
1
LIST OF PRACTICALS:
2 Write a program to show statistics of characters in the given line(to count the
number of alphabets ,digits, uppercase,lowercase,spaces and other characters).
2
3 Write a program to display frequencies of all the elements of a list.
4 Write a program to display those strings which are starting with ‘A’ from the
given list.
3
5 Write a program to find and display the sum of all the values which are ending
with 3 from a list.
4
8 Write a program to accept values from a user and create a tuple.
9 Write a program to input name of ‘n’ countries and their capital and currency
store, it in a dictionary and display in tabular form also search and display for a
particular country.
11 Assume that a text file named file1.txt contains some text, write a program
named that reads the file file1.txt and creates a new file named file2.txt, which
shall contain only those words from the file file1.txt which don’t start with a
vowel
5
12 Write a program to show and count the number of wordsin a text file
‘DATA.TXT’ which is starting with an word‘The’, ‘the’.
13 Write a program to read data from a text file DATA.TXT, and display each
words with number of vowels and consonants.
14 Write a program to read data from a text file DATA.TXT, and display word
which have maximum/minimum characters.
6
15 Consider a binary file “Emp.dat” containing details such as empno:
ename:salary(separator‘:’).Write a python function to display details of those
employees who are earning between 20000 and 40000.
16 Radha Shah is a programmer, who has recently been given a task to write a
python code
to perform the following CSV file operations with the help of two user defined
functions/modules:
a. CSVOpen() : to create a CSV file called BOOKS.CSV in append mode
containing
information of books – Title, Author and Price.
b. CSVRead() : to display the records from the CSV file called BOOKS.CSV
where the field
title starts with 'R'.
7
17 Following is the structure of each record in a data file named
”PRODUCT.DAT”.
{"prod_code":value, "prod_desc":value, "stock":value}
The values for prod_code and prod_desc are strings, and the value for stock is
an integer.
Write a function in PYTHON to update the file with a new value of stock. The
stock and the product_code, whose stock is to be updated, are to be input
during the execution of the function.
8
18 Assuming the tuple Vehicle as follows:
( vehicletype, no_of_wheels)
Where vehicletype is a string and no_of_wheels is an integer.
Write a function showfile() to read all the records present in an already existing
binary file SPEED.DAT and display them on the screen, also count the number
of records present in the file.
9
19 Write a MENU DRIVEN program to show push and pop operation using stack.
10
20 Write a Python program to create a dictionary from a string. .
Note: Track the count of the letters from the string.
Sample string : 'computeerr'
Expected output: {c:1 ,o:1,m:1 , p:1, u,:1 ,t:1 , e:2 ,r:2}
11
21 Write a Python program to create a dictionary from a string. .
Note: Track the count of the letters from the string.
Sample string : 'computeerr'
Expected output: {c:1 ,o:1,m:1 , p:1, u,:1 ,t:1 , e:2 ,r:2}
12
22 Write a Program in Python to sort a tuple of tuples by 2nd item
tuple1 = (('a', 23),('b', 37),('c', 11), ('d',29))
Expected output:
(('c', 11), ('a', 23), ('d', 29), ('b', 37))
23 Write a python program to connect to your database server and print its version
13
24 Write a python program with Mysql connectivity based on above table:
Hospital
Hospital_id Hospital_Name Bad Count
1 Apollo Hospital 200
2 Yashoda Hospital 400
3 Max Hospital 1000
4 Life Hospital 1500
Doctor
Doctor_id Doctor_Name Hospital_id Joining_Date Speciality Salary Exp.
101 Dr. Anuj 1 2005-12-05 Oncologist 250000 Null
102 Dr. Amit 2 2012-11-22 Radiologist 260000 Null
103 Dr. Rajni 2 2013-11-12 Pediatric 270000 Null
104 Dr. Jyoti 4 2008-07-03 Oncologist 210000 Null
ii Get the list of doctors as per the given specialty and salary
14
iii Get a list of doctors from a given hospital
15