2
LANCER’S CONVENT
PRASHANT VIHAR, ROHINI, DELHI-110085
COMPUTER SCIENCE
PRACTICAL FILE
(2022-2023)
NAME: ISHIKA GUPTA
ADMISSION NUMBER: 12118
CLASS/ SECTION: XII B
1. Write a program that accepts a string as a parameter to a function
and counts the number of upper case letters and lower case
letters.
OUTPUT
1
2. Write a python program to find the factorial of a number.
Provide the function with default parameters if no user input is
provided. (Factorial of negative numbers is not possible.)
OUTPUT
2
3. Write a program to demonstrate the concept of scope of a
variable.
OUTPUT
3
4. Write a Python function to create and print a list where the values
of the list are square of numbers between 1 and 30 (both
included).
OUTPUT
4
5. Write a program to input 10 numbers from the user and count
how many of these are whole numbers.
OUTPUT
5
6. Create a function calculator () to perform basic mathematical
operations and return multiple values and print them
individually.(needs correction)
OUTPUT
6
7. Read a text file line by line and display each word separated by a
#.
OUTPUT
7
8. Read a text file and display the number of
vowels/consonants/uppercase/lowercase characters in the file.
8
OUTPUT
9
9. Copy the contents of one text file to another text file by removing
all the lines that contain the character 'a'.
OUTPUT
10
[Link] a program to read a text file and display each word
starting from the 2nd letter.
OUTPUT
11
[Link] a binary file with name and roll number. Search for a
given roll number and display the name, if not found display
appropriate message.
12
OUTPUT
13
12. Create a binary file with roll number, name and marks. Input
a roll number and update the marks.
14
OUTPUT
15
13. Write a random number generator that generates random
numbers between 1 and 6 (simulates a dice).
OUTPUT
16
14. Write a program to read the contents of “[Link]” file
using with open().
OUTPUT
17
15. Create a CSV file by entering user-id and password, read
and search the password for given user-id.
OUTPUT
18
16. Write a function file_long() that accepts a file name and
reports the file’s longest line.
OUTPUT
19
17. Write a program to count the number of records present in
“[Link]” file.
OUTPUT
20
18. Create the following table:
Table: SchoolBus
(a) To show all information of students where capacity is more than the
no of student in order of rtno.
(b)To show area_covered for buses more than 20 km., but charges less
than 80000.
21
(c) To show the area covered by Bhalla Co. and kisan tours
d) To show the names of all the transporters without repeating their
names.
e) To show all the bus routes number where the distance is less than
30.
22
f) To show the area whose names end with ‘r’ in decreasing order of
the area covered.
g) To show rtno, area_covered and average cost per student for all
routes where average cost per student is - charges/noofstudents
h) To show the number of areas covered by all the bus routes
i) To show the number of area covered by each transporter.
23
j) To show the maximum capacity of a bus
k) To show transporter wise total number of students traveling.
l) Add new record with data: (11, “ Moti bagh”,35,32,10,” kisan tours
“, 35000)
m) Give the output considering the original relation as given :
i. select sum(distance) from schoolbus where transporter= “
Yadav Co.”;
24
ii. select min (noofstudents) from schoolbus;
iii. select avg(charges) from schoolbus where transporter= “Anand
travels”;
iv. select distinct transporter from schoolbus ;
25
v. select count(distinct transporter) from schoolbus ;
vi. select count(*) from schoolbus ;
vii. select transporter, count(*) from schoolbus group by
transporter ;
26
viii. select transporter, max(charges) from schoolbus group by
transporter ;
27
19. Consider the two tables EMPLOYEE and DEPT
Table :Employee
Table:DEPT
a) Show the minimum, maximum and average salary of
Managers.
28
b) Display the designation wise list of employees with name, Sal
and date of joining.
c) Count the number of Clerks in an organization.
d) Count the number of employees who are not getting
commission.
e) Show the average salary for all departments with more than
or equal to 2 working people.
29
f) List the count of employees grouped by deptno.
g) Display the maximum salary of employees in each
department.
h) Display the name of employees along with their designation
and department name.
i) Count the number of employees working in Accounts
Department.
30
j) Display the name of employees who has name starting with
“A”.
k) Display the name of employees working in the same city
where they belong.
l) Display the name of employees who is managing sales
department.
m)Display the name who are working in Delhi and getting more
than 5000
31
n) Display the details of employees who are working in
Accounts Department.
o) Find out the name of all employees who are not working in
Mumbai.
32
20. Create the following table PRODUCT and CLIENT and
answer the questions given below.
Table: Product
Table: Client
(a) To display the details of those clients whose city is “delhi”.
(b)To display the details of products whose price is in the range of
50 to 100.
33
(c) To display the client name ,city from table client and
productname and price from the table product with their
corresponding matching p_id.
(d)To increase the price of the product by 10.
(e) Select distinct city from client.
34
21. Create the following table CONSIGNOR and
CONSIGNEE and perform the queries given.
Table:Consignor
Table: Consignee
(a) To display the names of all the consignors from Mumbai.
35
(b)To display the
cneeid,cnorname,cnoradress,cneenmae,cneeaddress for
every consignee.
(c) To display consignee details in ascending order of
cneename.
(d)To display number of consignee from each city.
e) Select distinct cneecity from consignee.
36
22. Create a table CLUB and perform the queries given below:
(a) Add a new column Mtype with datatype as varchar.
(b)Set member_id as the primary key.
(c) Assign NULL values for mytype column.
37
(d) Add a new column mdate and set all values to ’12-12-2021’.
(e) Show all records having email as NULL.
(f) Change the datatype & size of Member_id to character with size
4.
38
(g) Display member ID who reside in Delhi or Gurgoan.
(h)Display age of members whose fees is between 1500 and 2200.
(i) Print all member names starting with ‘N’.
(j) Find the total number of rows in the table.
39
(k) Execute the given queries:
a. Select distinct(fees) from club;
b. Select membername from club where address
IN(‘Gurgoan’,’Faridabad’);
c. Select * from club order by age desc;
d. Select sum(Fees) AS Total_fees from club;
40
e. Select Address,sum(Fees) AS Total_fees from club where
Address=’New Delhi’;
f. Alter table club drop primary key;
g. Update club set mytype=’golf’ where member_id=’M005’;
h. Select * from club;
41
i. desc club;
j. show databases;
k. show tables;
42
l. Remove the primary key constraint.
m. Delete any one table from the existing database.
43
23. Write a Python program to insert an element into a stack
and display all elements.
OUTPUT
44
24. Write a Python program to remove an element from a stack
and display all elements.
OUTPUT
45
25. Write a Python program to implement a stack using list and
display the element on top of the stack.
OUTPUT
46
26. Integrate SQL with Python by importing suitable module
and retrieve all records from the table product.
OUTPUT
47
27. Perform a delete query on the table products to delete the
product having price greater than 100 using Python MySql
connectivity.
OUTPUT
48