PRACTICLE FILE - -CS[1]-(changes)(2)
PRACTICLE FILE - -CS[1]-(changes)(2)
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
PYTHON
1 Write a function Search(L, element) for searching 08-07-2024
element in a list.
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
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: