0% found this document useful (0 votes)
26 views69 pages

CS Practicle

Uploaded by

nakiimam03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views69 pages

CS Practicle

Uploaded by

nakiimam03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 69

Practicle file

Session[2023-2024]
Name: Naki Imam
Class: XII-A
Roll No. :
• Text File
• Binary File
• CSV File
This practical file serves as a comprehensive guide for exploring computer science concepts
and implementing them using the Python programming language. Through a series of hands
on exercises and projects, this practical file aims to enhance our understanding of computer
science principles and strengthen our programming skills. Python, a versatile and beginner-
friendly programming language, has gained immense popularity in the field of computer
science due to its simplicity, readability, and extensive libraries. It provides a Powerful toolset
for solving real-world problems and implementing various algorithms and data structures.
This chapter deals with all the concept taught in class 11 that are basic for python
language

1. Program to sort a list

2. Program to shift negative elements on one side in list

3. Program to add ‘n’ number of items in list

4. Program to find largest and second largest no. from list

5. Program to input two tuples and swap their values

6. Program to perform linear search on tuple


Program to input a tuple of integers & find the maximum & minimum integer from the
7.
tuple
8. Program to count no. of occurrence of character in given string using dictionary
This chapter deals with defining and creating sub programs and functions

1. Finding area of different shapes using functions

2. Finding factorial using functions

3. Counting lowercase and uppercase characters using functions

4. Counting vowels in a string using functions


This chapter deals with programs libraries modules related to text file

1. Program to read & print the lines having length more than 50 in text files

2. Program to count no. of words in text files

3. Program to count no. of vowels, consonants & digits in text files

4. Program to count words starting with ‘P’ or ‘E’ in text files

5. Find the total no. of lines & total no. of words in a text file

6. Program to read & print the words having length more than 7 from text file

7. Program to make a employee record in a text file using writelines ()

8. Program to make a copy file of only those lines starting with uppercase letters
Program to append employees in the record and search those employees having salary
9.
more than 15000
This chapter deals with programs libraries modules related to binary file

1. Program for writing & reading students’ record in a binary file. (METHOD-1)

2. Program for writing & reading students’ record in a binary file. (METHOD-2)

3. Program to make a dictionary in binary files

4. Program to make a book record in binary files

5. Program for appending record in a binary file

6. Program for deleting a record in a binary file

7. Program for updating a record in a binary file

8. Program to store Gmeet Info in binary files


This chapter deals with the CSV files

1. Program to reading the csv file.

2. Program to display vowels present in the words entered by user

3. Program to push, pop , and display name and ID of the book in stack of book

4. Program to push,pop & display name and marks of students in stack of students
This chapter deals with the new algorithms

1. Program to showcase all functions of stack

2. Program to store students data in csv file

3. Program to search a student’s record

4. Program to write in a csv file using writerow() function


SQL (Structured Query Language) is a domain-specific language used for managing and
querying relational databases, facilitating data storage, retrieval, and manipulation.

1. Database containing LOANS table

2. Database containing PRODUCT & CLIENT table

3. Database containing COMPANY & MODEL table

4. Database containing STOCK & DEALER table

5. Database containing CARDEN table

6. DATABASE CONNECTIVITY
‘ ’
‘ ’ ‘ ’


Initial
Entries

AccNo. Cust_Name Loan_Amount Installments Int_Rate Start_Date Interest

1. R.K. Gupta 30000 36 12.00 2009-07-19 1200

2. S.P. Sharma 50000 48 10.00 2008-03-22 1800

3. K.P. Jain 30000 36 NULL 2007-03-08 1600

4. M.P. Yadav 80000 60 10.00 2008-12-06 2250

5. S.P. Sinha 20000 36 12.50 2010-01-03 4500

6. P. Sharma 70000 60 12.50 2008-06-05 3500

7. K.S. Dhali 50000 48 NULL 2008-03-05 3800


(I) Display the sum of all Loan Amounts whose interest rate is greater than 10.
Ans: Mysql> SELECT SUM(Loan_Amount) FROM LOANS WHERE Int_Rato>10;

(ii) Display the Maximum Interest from Loans table.


Ans: Mysql> SELECT MAX(Interest) FROM LOANS;

(iii) Display the count of all loan holders whose name ends with 'Sharma’.
Ans: Mysql> SELECT COUNT(*) FROM LOANS WHERE Cust_Name LIKE ‘%Sharma’;

(iv) Display the count of all loan holders whose Interest rate is Null.
Ans: Mysql> SELECT COUNT(*) FROM LOANS WHERE Int_Rate IS NULL;

(v) Display the Interest-wise details of Loan Account Holders.


Ans: Mysql> SELECT * FROM LOANS ORDER BY Interest;
P_ID Product_Name Manufacture Price C_ID Client_Name City P_ID
TP01 Talcum Powder LAK 40 01 Cosmetic Shop Delhi FW05
FW05 Face Wash ABC 45 06 Total Health Mumbai BS01
BS01 Bath Soap ABC 55 12 Live Life Delhi SH06
SH06 Shampoo XYZ 120 15 Pretty Woman Delhi FW12

FW12 Face Wash XYZ 95 16 Dreams Bengaluru TP01


(i)To display the details of those Clients whose city is Delhi.
Ans: SELECT * FROM CLIENT WHERE City = “Delhi”;
(ii)To display the details of Products whose Price is in the range of 50 to 100(both
values included).
Ans: SELECT * FROM PRODUCT WHERE PRICE BETWEEN 50 and 100;
(iii)To display the details of those products whose name ends with 'Wash'.
Ans: SELECT * FROM PRODUCT WHERE Product_Name LIKE ‘%Wash';
(iv) To display C_ID. ClientName. City of all the clients(including the ones that have
not purchased a product) and their corresponding Product_Name sold.
Ans: SELECT C_ID, Client_Name, City, Product_Name FROM Client LEFT JOIN Product
ON Client. P_ID = Product.P_1D;
(v) To display total number of records in the Product table on the basis of
Manufacturer with no duplicate values.
Ans: SELECT COUNT(DISTINCT Manufacturer) FROM Product;
Model C_ID Cost DateOfManufacture
C_ID CompName CompHO ContactPerson
_ID
1 Titan Okhla C.B. Ajit T020 1 2000 2010-05-12
2 Ajanta Najafgarh R. Mehta M032 4 7000 2009-04-15
3 Maxima Shahdara B. Kohli M059 2 800 2009-09-23
4 Seiko Okhla R. Chadha A167 3 1200 2011-01-12
5 Ricoh Shahdara J. Kishore T024 1 1300 2009-10-14
(i) TO display details Of all models in the Model table in ascending order Of dateOf
Manufacture
Ans: SELECT * FROM Model ORDER BY DATEOfManufacture;
(ii) TO display details Of those models manufactured in 2011 and whose Cost is below
2000
Ans: SELECT * FROM Model WHERE year(DateOfManufacture)=2011 And Cost<2000;
(iii) To display the Model_ID, C_ID, Cost from the table Model, Compname
and ContactPerson from Company table. with their corresponding comp_lD.
Ans: SELECT Model _ ID, C_ID, Cost, CompName, ContactPerson FROM Model,
Company WHERE MODEL .C_ID = Company.C_ID;
(iv) To decrease the cost of all the models in Model table by 15%.
Ans: UPDATE Model SET Cost = Cost - 0.15*Cost;
(v) To display total number of records in the Company table on the basis of CompHO
with no duplicate values.
Ans: SELECT COUNT(DISTINCT CompHO) FROM Company;
ItemNo Item Dcode Qty UnitPrice StockDate

5005 Ball Pen 102 100 16 2011-03-31


0.5
5003 Ball Pen 102 150 20 2010-01-01
0.25 Dcode DName

5002 Gel Pen 101 125 14 2010-02-14 101 Reliable Stationers


Premium
103 Class Plastics
5006 Gel Pen 101 200 11 2009-01-09
Classic 104 Fair Deals
5001 Eraser 102 210 4 2009-03-19 102 Clear Deals
Small
5004 Eraser 102 60 10 2010-12-12
Big
5009 Sharpne 103 260 8 2010-01-23
r Classic
(i) To display details of all models in the Stock table in ascending order of Stock Date
Ans: SELECT * FROM Stock ORDER BY StockDate;
(ii) TO display details Of those models whose Dealer Code(Dcode) is 102 or quantity in
Stock(Qty) is more than 100.
Ans: SELECT * FROM Stock WHERE Dcode = 102 OR Qty > 100;
(iii) TO insert a record in the Stock table with the values: (5010. 'Pencil HB'. 102. 500. 10.
'2010-01-26')
Ans: INSERT INT0 Stock VALUES (5010, 'Pencil HB', 102, 500, 10, '2010-01-26’);
(iv) TO display Dcode, Dname from Dealer table and Item. UnitPrice from Stock table
of all the Dealers (including the dealer details that have not sold any item)
Ans: SELECT Dealer, Dcode, Item,UnitPrice FROM Dealer LEFT JOIN Stock ON Dealer.
Dcode = Stock. Dcode
(v) TO display the product of Qty & UnitPrice from the table Stock whose ItemNo is
5006.
Ans: SELECT Qty*UnitPrice FROM Stock WHERE ItemNo=5006;
CCode CarName Make Color Capacity Charges

501 A-Star Suzuki Red 3 14

503 Indigo Tata Silver 3 12

502 Innova Toyota White 7 15

509 SX4 Suzuki Silver 4 14

510 C Class Mercedes Red 4 35


(i) To display the names of all the silver-coloured cars.
Ans: SELECT * FROM CARDEN WHERE color = ‘Silver’;
(ii) To display name, make and capacity of cars in descending order of their
sitting capacity.
Ans: SELECT CarName, Make, capacity FROM CARDEN ORDER BY capacity DESC;
(iii) To display the highest charges at which a vehicle can be hired from CARDEN
Ans: SELECT MAX(Charges) FROM CARDEN;
(iv) To display the names of all the cars whose Capacity is greater than 3.
Ans: SELECT CarName FROM CARDEN WHERE Capacity>3;
(v) To display total number of records on the basis of Make with
no duplicate values.
Ans: SELECT COUNT(DISTINCT Make) FROM CARDEN;
“In conclusion, this practical work has been
an enriching experience that has expanded
my understanding of various computer
science concepts and their real-world
applications. It has equipped me with
valuable skills that I can apply in both
academic and professional settings. I have
thoroughly enjoyed the challenges and
opportunities that this course has offered.”

You might also like