yash cs

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 30

COMPUTER SCIENCE

PRACTICAL FILE

SESSION: 2023-24
CLASS: XII-A

Submitted by: Yash Dutt


Submitted to: Mrs. Ujjwal Garg
1.Read a text file line by line and display each word separated by
a #.

OUTPUT:

2.Read a text file and display the number of vowels/


consonants/ uppercase / lowercase characters
OUTPUT:

3.Remove all the lines that contain the character 'a' in a file and
write it to another file.

Input File:
OUTPUT:

4.Create a binary file with name and roll number. Search for a given roll
number and display the name, if not found display appropriate message.
OUTPUT:

5.Create a binary file with roll number, name and marks. Input a
roll number and update the marks.

OUTPUT:

6.Write a random number generator that generates a


random number between 1 and 6 (simulates a dice).
OUTPUT:

4
7.Write a Python program to implement a stack using list.

OUTPUT:
8.Create a CSV file by entering user-id and password, read
and search the password for given user id.

OUTPUT:

9.Find the factorial of a natural number.

OUTPUT:

10.Find the sum of all elements of a list.


OUTPUT:

11.Write a recursive code to compute the nth Fibonacci


number.

OUTPUT:
12.Write a binary program to read, search, update, delete
records.
OUTPUT:
13.Program to write data onto “student” CSV file using
writerow() method.
OUTPUT:

14.Write a program to find the roots of a quadratic function.

Output:
15.Write a menu -driven program for performing all the operations on a
table 'student'.
OUTPUT:
4 Programs based on Python – Sql
connectivity

The operations on Mysql table “emp” involve reading,updating,


and deleting records of employees.

16.Program to read and fetch all the records from EMP


table having salary more than Rs. 70000.

OUTPUT :
17.Program
to update the records of employees
by increasing salary by Rs. 1000 of all those employees
whoare getting less than Rs. 80000.

Output :
18.Program
to delete the record on the basis of inputted
salary.

Output :
19.Program

to insert the student details in the student table.


5 sets of Sql queries
Set
1
1.Create a student table and insert data. Implement the
followingSQL commands on the student table:

1. ALTER table to add new attributes / modify data type / drop attribute

OUTPUT:

2.UPDATE table to modify data


3.ORDER By to display data in ascending / descending order.

4.DELETE to remove tuple(s)

OUTPUT:

5.GROUP BY and find the min, max, sum, count andaverage


Set 2
Q.Consider the table company and model

Write the SQL commands for the Queries:


1.To display details of all models in th eModel table in ascending order
of the DateOfManufacture.
SELECT * FROM Model ORDER BY DateOfManufacture;

2.To display details of those models manufactured in 2011 and whose cost isbelow 2000
SELECT * FROM Model WHERE year (DateOfManufacture) = 2011 AND Cost <2000;

3.To display the Model_ID, Comp_ID, Cost from the table Model, CompNameand
ContactPerson from Company table , with their corresponding Comp_ID.
SELECT Model _ID, Comp_ID, Cost, CompName, ContactPerson FROMModel,
Company WHERE Model.Comp_ID = Company.Comp_ID;

4.To decrease the cost of all the models in Model table by 15%
UPDATE Model SET Cost = Cost - 0.15*Cost;

5.SELECT COUNT(DISTINCT CompHO) FROM Company;


SET 3
Q.Consider the table employee and salgrade given below

(A).Write SQL commands for the following statements:


1.To display the details of all EMPLOYEEs in descending order of DOJ
SELECT * FROM EMPLOYEE ORDER BY DOJ DESC;
2.To display NAME and DESIG of those EMPLOYEEs whose SALGRADE is eitherS02 or S03;
SELECT NAME,DESIG FROM EMPLOYEE WHERE SGRADE=’S02’ OR SGRADE=’S03’;

3.To display the content of the entire EMPLOYEEs table, whose DOJ is
inbetween ‘09-Feb-2006’ and ‘08-Aug-2009’
SELECT * FROM EMPLOYEE WHERE DOJ BETWEEN ‘2006-02-09’ AND ‘2009-08-
02’
4.To add a new row with the following content:
109,’Harish Roy’,’HEAD-IT’,’S02’,’9-Sep-2007’,’21-Apr-1983’
INSERT INTO EMPLOYEE VALUES(109, ‘Harish Roy’, ‘HEAD-IT’, ‘S02’, ‘2007-09-09’,‘1983-04-21’);

(B).Give the output of the following SQL queries:


1.SELECT COUNT(SGRADE), SGRADE FROM EMPLOYEE GROUP BY SGRADE;

2.SELECT MIN(DOB), MAX(DOJ) FROM EMPLOYEE;

3.SELECT SGRADE, SALARY+HRA FROM SALGRADE WHERE SGRADE = ‘S02’;

Set 4
TABLE – teacher
1.To show information about the teacher of the History
department. select * from teacher where DEPT=”History”;

2.To list the name of female student who are in Hindi


department . select * from student where
department=”hindi” and sex=”f”;

3.To list the name of all student with their data of admission in ascending order.
select * from student order by dataofadm;

4.To display students name , fee , age for male


students only. select name , fee , age of student where
sex =”m”;

5.To count the number of student with


Age>23.
select count(*) from student age>23;
SET 5
TABLE-HOSPITAL

1.To increase the charges of all the patients by 5% .


update hospital set charges= charges+(charges*5)/100;

2.To remove the record of the patient whose name is tarun .


delete from hospital where name = “tarun”;

3.To add another column DocName (Doctor Name) of the type varchar in the above table.
alter table hospital add DocName varchar(20);
4.To display patient detail whose age is missing(null).
select* from hospital where age is NULL;

5.To decrease the charges by 5% of all the patients admitted to the ENT department.
update hospital set charges = charges-(charges*5)/100 where department =”ENT”;

You might also like