0% found this document useful (0 votes)
15 views60 pages

PRACTICLE FILE - -CS[1]-(changes)(2)

This document is a practical file for Computer Science by Ritvik Mahajan for the academic year 2024-25, including a certificate of authenticity and acknowledgments. It contains an index of Python and SQL programming tasks, detailing various functions and programs to be implemented, along with their respective dates. The document serves as a comprehensive record of practical exercises and projects completed in the course.

Uploaded by

walk master
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)
15 views60 pages

PRACTICLE FILE - -CS[1]-(changes)(2)

This document is a practical file for Computer Science by Ritvik Mahajan for the academic year 2024-25, including a certificate of authenticity and acknowledgments. It contains an index of Python and SQL programming tasks, detailing various functions and programs to be implemented, along with their respective dates. The document serves as a comprehensive record of practical exercises and projects completed in the course.

Uploaded by

walk master
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/ 60

PRACTICAL FILE

COMPUTER SCIENCE
SESSION 2024-25
NAME: Ritvik Mahajan
CLASS: XII-C
BOARD ROLL NO:
SCHOOL: MAXFORT SCHOOL DWARKA, NEW DELHI
Certificate
Name: Ritvik Mahajan
Class: XII – C
Roll No:
This is certified to be the bonafide work
of the student in the Computer Science
Practical File during the academic year
2024 – 2025

Signature of Teacher Signature of Examiner

Date: Signature of HOS


Acknowledgement
I wish to express my great gratitude and sincere thanks
to the HOS, Ms. Dipika Sharma for her encouragement
and all the facilities which were provided to complete
the File. I sincerely appreciate her efforts for taking
me into her fold for which I shall remain forever in
debt.

I extend my heartiest thanks to Ms. Bhumika Dwivedi,


our Computer Science teacher, who guided me towards
the successful completion of this file. I take this
opportunity to express my sincere gratitude for her
immense guidance constant encouragement and
motivation which has sustained my efforts at all stages
of this file.
PYTHON
INDEX
S.N. PROGRAM DATE SIGN

PYTHON
1 Write a function Search(L, element) for searching 08-07-2024
element in a list.

2 Write function Frequency() which prints the 08-07-2024


frequency of each element in the list.

3 Write a Python Program to input n numbers in tuple and 08-07-2024


pass it toa function to count how many even and odd
numbers are entered.

4 Write a function which takes input the key and 09-07-2024


value, and update value of that key in a
dictionary.
5 Write a program to input names of countries and 09-07-2024
their capital and currency, store it in a dictionary and
display it in tabular form. Also search and display
details of a particular country.
6 Write a program that generates random number 12-07-2024
between two numbers.

7 Program to read a string, count and display the 12-07-2024


number of alphabets, digits, spaces and special
characters in the string.
8 A menu-driven python program to implement stack 09-08-2024
operation.
9 Python program to check whether a string is a 09-08-2024
palindrome or not using stack.

10 Write a python program using function 12-08-2024


PUSH(Arr), where Arr is a list of numbers. From
this list push all numbers divisible by 5 or 7 into a
stack implemented by using a list. Display the
stack if it has at least one element, otherwise
display appropriate error message.
11 Consider a nested list structure 13-08-2024
BooksData = [[BookName, Author, Genre,
Price], storing selection of books available in the
local library. Write the below functions in Python
to implement stack functionality:
i. PushData() : The function check the list and
pushes thename and price of the books whose
genre is “science- fiction”.
ii. PopData(): To Pop the data from the stack and
display them. Also, display "Underflow" when
there are no data in the stack.
For example: If the list contains the following
data:BooksData = [["Dystopian",
"Frank Herbert",”science-
fiction”, 250], ["The Twilight
Saga ","Stephenie
Meyer",”Romantic”,350],["1984","
George-Orwell",”science-fiction”,
150],["The Diary of a Young
Girl","Anne
Frank","biography",200],["The
Time-Machine","H.G.
Wells"," science-fiction",150]]
The output
should be: The
Time Machine,
150
Dystopian,250
Underflow
12. Assuming a given dictionary, Write the following 13-08-2024
methods:PushData() : The function add new
elements in the stack.
Add only those country names whose capitals
consists of letters „A‟ and „I‟
PopData(): To Pop the data from the stack and
display them. Also, display "Empty stack" when
there are no data in the stack.
countries = {“INDIA”: “NEW
DELHI”, “PAKISTAN”:
“ISLAMABAD”, “AFGANISTAN”:
“KABUL”,“IRAN”: “TEHRAN”,
“VIETNAM”: “HANOI”}
The output
should be:
VIETNAM
PAKISTAN
Empty stack
13. Program to read and display a text file content 19-08-2024
line by line with each word separated by #.
14. Program to remove all the lines that contain 19-08-2024
character „a‟ in a text file and write it to another
file.
15. Program to read characters one by one from 20-08-2024
keyboard, all lower-case characters to be stored
in file „lower‟ and all uppercase in file „upper‟
while other characters should be stored in file
„others‟
16. Create a CSV file by entering user-id and 07-10-2024
password, read and search the password for
given user- id.
17. Write a program in Python that defines and calls the 07-10-2024
following user defined functions:
Add_Emp() : Takes the details of the employees
and adds them to a csv file Emp.csv'. Each record
consists of a list with field elements as ADM_NO,
NAME and AGE to store admin number, name and
age of the employee respectively.
Retired() : Read the csv file and copy the details of
the employee who are 59 years old and about to
retire in the
coming year to a new CSV file Farewell.csv.
18. Create a binary file with roll no. and marks. Search 11-10-2024
for a given roll number and update the marks as per
given by user.
19. Amit is a monitor of class XII-A and he stored the 11-10-2024
record of all the students of his class in a file named
“XIIA.dat”.
Structure of record is [roll number name, [Phy, Chem
,Maths]]. Marks are out of 100.
For example: if the data in the binary file is given as
below:
[1,'Akhilesh',[30,45,38]]
[2,'Bhawna',[95,92,98]]
[3,'Chanchal',[77,42,16]]
[4,'Abhilasha',[91,87,96]]
[5,'Preeti',[35,55,33]]
The output should be-
Students who need remedial classes
in Maths:
Akhilesh
Chanchal
Preeti
Students who are showing brilliant academic
performance:
Bhawna Abhilasha
20. ABC infotech Pvt Ltd. needs to create a database 30-04-24
for their digital account. Develop
an interface that provides front-end interaction with
Python.
Write Python program
with separate user defined functions to perform the
following tasks:
a. Create a database abc_office
b. Create a table Employees with fields EmpId,
Name, Age,
Gender and Salary
c. Insert data into table
21. For ABC infotech create a function to connect to 30-04-24
the database and retrieves all records and displays
total number of records.

22. Write a program to read and fetch all the records 30-04-24
from employees table having salary more than
30000.
23. For ABC infotech Write a program to increase the 30-04-24
salary by5% where employee if is 104.

SQL

SN. SQL Query DATE SIGN

1. Write SQL query to create a database named


09-04-24
„Company‟.

2. Write SQL query to open the database.


09-04-24

3. Write SQL query to create following Tables:

Employee (EmpNo, EName,


DOB, DOJ,Salary, 09-04-24
Designation,
Deptld,Department(Dept
Id, DeptName,
DeptHeadID)
4. Write SQL query to show the structure of tables.
09-04-24

5. Write SQL query to insert 10 records in each table.


09-04-24
6. Write SQL query to display all the records from
tables. 09-04-24

7. Write SQL query to display EmpNo and EName


of all employees from the table Employee 16-04-24

8. Display the details of all employee whose annual


salary is between 25000 to 4000. 16-04-24

9. Display details of all the employees in descending


order of their salaries. 16-04-24

10. Display the details of employees whose name have


only four letters 16-04-24

11. Display the name of employee whose name


contains A as third letter. 16-04-24

12. Display the name of employee whose name


contains L at any position. 16-04-24

13. Display the name of departments. Each department


should be displayed once. 16-04-24

14. Display name, designation and salary of employee


who do not have manager. 16-04-24

15. Add a new column Bonus in the Employee table


and keep the default value as 1000. 23-04-24

16. Update the Bonus as 10 % of the salary. 23-04-24


17. Add DeptId as the primary key of Department. 23-04-24
18. Make the Ename as not null. 23-04-24
19. Delete the record of the employee with EmpId 1011. 23-04-24
20. Calculate the avg salary of the employees.
23-04-24
21. Display DeptId and no. of employees in the
23-04-24
Department.
22. Show the employee Names and their Department
23-04-24
Head.
Q.1. write a function Search (L, element)
for searching element in a list.

Code:

Output:
Q.2. Write a function frequency() which
prints the frequency of each element in
the list.

Code:

Output:
Q.3. Write a Python Program to input n
numbers in tuple and pass it to a function
to count how many even and odd numbers
are entered.

Code:

Output:
Q.4. Write a function which takes input
the key and value, and update value of
that key in a dictionary.

Code:

Output:
Q.5. Write a program to input names of
countries and their capital and currency,
store it in a dictionary and display it in
tabular form. Also search and display
details of a particular country.

Code:

Output:
Q.6. Write a program that generates
random number between two
numbers

Code:

Output:
Q.7. Program to read a string, count and
display the number of alphabets, digits,
spaces and special characters in the
string.

Code:

Output:
Q.8. A menu-driven python program to
implement stack operation.

Code:
Q.9. Python program to check whether a
string is a palindrome or not using
stack.

Code:

Output:
Q.10. Write a python program using
function PUSH(Arr), where Arr is a list of
numbers. From this list push all numbers
divisible by 5 or 7 into astack implemented
by using a list. Display the stack if it has at
least one element, otherwise display
appropriate error message.
Code:

Output:
Q.11. Consider a nested list structure BooksData =
[[BookName, Author, Genre, Price]],
storing selection of books available in the local library. Write the
below functions in Python to implement stack functionality:
i.) PushData() : The function check the list and pushes the
name and price of the books whose genre is “science- fiction”.
ii.) PopData(): To Pop the data from the stack and display them.
Also, display "Underflow" when there are no data in the stack.
Code:

Output:
Q.12. Assuming a given dictionary, Write the
following methods:
1) PushData() : The function add new elements in the
stack. Add only those country names whose capitals
consists of letters ‘A’ and ‘I’
2) PopData(): To Pop the data from the stack and display
them. Also, display "Empty stack" when there are no
data in the stack.
Code:

Output:
Q.13. Program to read and display a text
file content line by line with each word
separated by #.
Code:

Output:
Q.14. Program to remove all the lines that
contain character “a” in a text file and write
it to another file.

Code:

Input.txt: Output.txt:
Q.15. Program to read characters one by
one from keyboard, all lower-case
characters to be stored in file “Lower” and all
uppercase in file “Upper” while other
characters should be stored in file “others”.
Code:

Output:
Q.16. Create a CSV file by entering user-id
and password, read and search the
password for given user- id.

Code:

Output:
Q.17. Write a program in Python that defines
and calls the following user defined
functions:
1) Add_Emp() : Takes the details of the employees and
adds them to a csv file Emp.csv'. Each record consists
of a list with field elements as ADM_NO, NAME and
AGE to store admin number, name and age of the
employee respectively.
2) Retired() : Read the csv file and copy the details of the
employee who are 59 years old and about to retire in the
coming year to a new CSV file Farewell.csv.
Code:
Output:
Q.18. Create a binary file with roll no. and
marks. Search for a given roll number and
update the marks as per given by user.
Code:

Output:
Q.19. Amit is a monitor of class XII-A and he
stored the record of all the students of his
class in a file named “XIIA.dat”. Structure of
record is [roll number ,name, [Phy, Chem,
Maths]]. Marks are out of 100.
Code:

Output:
Q.20. ABC infotech Pvt Ltd. needs to
create a database for their digital account.
Develop an interface that provides front-
end interaction with Python. Write Python
program with separate user defined
functions to perform the following tasks:
a. Create a database abc_office
b. Create a table Employees with fields EmpId,
Name, Age, Gender and Salary
c. Insert data into table
Code:
Output:
Q.21For ABC infotech create a function to
connect to the database and retrieves all records
and displays total number of records.

Code:

Output:
Q.22. Write a program to read and fetch all the
records from employees table having salary
more than 30000.

Code:

Output:
Q.24. For ABC infotech Write a program to
increase the salary by 5% where employee if
is 104.

Code:

Output:
SQL
1. Write SQL query to create a
database named “Company”.

Code:
create database Company;

Output:
2. Write SQL query to open the database.

use Company;
3. Write SQL query to create following
Tables: Employee (EmpNo, EName,
DOB, DOJ, Salary, Designation,
Deptld) Department (DeptId,
DeptName, DeptHeadID) .
Code:

Output:
4. Write SQL query to show the structure of
tables.

Code:

Output:
5. Write SQL query to insert 10 records in each
table.
Code:
Output:
6. Write SQL query to display all the records
from tables.
Code:

Output:
7. Write SQL query to display EmpNo and
EName of all employees from the table
Employee

Code:

Output:
8. Display the details of all employee whose
annual salary is between 25000 to 40000.

Code:

Output:
9. Display details of all the employees in
descending order of their salaries.
Code:

Output:
10. Display the details of employees whose name
have only four letters.

Code:

Output:
11. Display the name of employee whose name
contains A as third letter.

Code:

Output:
12. Display the name of employee whose name
contains L at any position.

Code:

Output:
13. Display the name of departments. Each
department should be displayed once.

Code:

Output:
14. Display name, designation and salary of
employee who do not have manager.

Code:

Output:
15. Add a new column Bonus in the Employee
table and keep the default value as 1000.

Code:

Output:
16. Update the bonus as 10% of the salary.

Code:

Output:
17. Add Dept Id as the primary key of
Department.

Code:
18. Make the E name as not null.

Code:

Output:
19. Delete the record of the employee with
Emp Id1011.

Code:
20. Calculate the avg salary of

the employees.

Code:

Output:
21. Display DeptId and no. of employees
in the Department

Code:

Output:
22. Show the employee Names and their
Department Head.

Code:

Output:

You might also like