0% found this document useful (0 votes)
43 views

CLASS XII CS LIST OF PRACTICALS 2024-25 (2)

Uploaded by

farhaanzilani
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)
43 views

CLASS XII CS LIST OF PRACTICALS 2024-25 (2)

Uploaded by

farhaanzilani
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/ 7

COMPUTER SCIENCE

Part A: List of Practicals

1. Queries Set 1 (Based on DDL commands & DML command INSERT)

Suppose your school management has decided to conduct cricket matches between students of Class XI
and Class XII. Students of each class are asked to join any one of the four teams – Team Titan, Team
Rockers, Team Magnet and Team Hurricane. During summer vacations, various matches will be
conducted between these teams. Help your sports teacher to do the following:
a) Create a database “Sports”.
b) Create a table “TEAM” with following considerations:
a. It should have a column ‘TeamID’ for storing an integer value between 1 to 9, which refers to
unique identification of a team.
b. Each ‘TeamID’ should have its associated name ‘TeamName’, which should be a string of
length not less than 10 characters. Use the appropriate column- level constraint.
c. Using table level constraint, make ‘TeamID’ as the primary key.
c) Show the structure of the table TEAM using a SQL statement.
d) Add a new attribute ‘Team_Color’of size 10 characters to the table TEAM.
e) Insert these four rows in TEAM table:
a. Row 1: (1, Titan, Red)
b. Row 2: (2, Rockers, Blue)
c. Row 3: (3, Magnet, Yellow)
d. Row 3: (4, Hurricane, Green)
f) Now create another table MATCH_DETAILS and insert data as shown below. Choose appropriate
data types and constraints for each attribute. The attributes ‘FirstTeamID’ and ‘SecondTeamID’
should refer the primary key ‘TeamID’ of the parent table TEAM.

MatchID MatchDate FirstTeamID SecondTeamID FirstTeamScore SecondTeamScore


M1 2021/12/20 1 2 107 93
M2 2021/12/21 3 4 156 158
M3 2021/12/22 1 3 86 81
M4 2021/12/23 2 4 65 67
M5 2021/12/24 1 4 52 88
M6 2021/12/25 2 3 97 68

g) Rename the attributes ‘FirstTeamScore’ and ‘SecondTeamScore’ to ‘FTscore’ and ‘STscore’ respectively.
h) Change the data type of ‘FTscore’ and ‘STscore’ to decimal.
2. Queries Set 2 (Fetching records using SELECT)

Consider the following table named ‘Exam’ with details of marks. Write SQL commands for (i) to
(v) and outputs for (vi) to (viii).
Table: Exam
Adno SName Percentage Class_section Stream
R001 Sushant 90.2 12A Science
R002 Vaidyanath 80.5 12B Humanities
R003 Miara 68.9 12B Science
R004 Niara 96.0 12A Commerce
R005 Shinjini 88.9 12D Commerce

(i) To display all information of the students of science in descending order of percentage.
(ii) To display Adno, Name, Percentage and Stream of those students whose name is less than
6 characters long.
(iii) To display all students who have ‘i’ anywhere and ‘a’ at the last position in their names.
(iv) To display names and streams of students whose have got between 85% and 95%.
(v) To display all different class sections.
(vi) SELECT COUNT(*) FROM EXAM;
(vii) SELECT Sname, Percentage FROM EXAM WHERE Name LIKE “N%”;
(viii) SELECT ROUND(Percentage,0) FROM EXAM WHERE Adno=”R005”;

3. Queries Set 3 (Based on Aggregate Functions and GROUP BY clause)

Consider the following table ‘Gym’. Write SQL commands for (i) to (viii).

(i) To count the number of members of each type for the Gym.
(ii) To display the membership type alongwith the maximum and minimum fees of each
type.
(iii) To display types of memberships available. Duplicate values should not be
displayed.
(iv) To display total fee given by each gender in Gym.
(v) To display the average age of each gender in Gym.
(vi) To display sum of fee given in each membership type.
(vii) To display maximum fees given by monthly type members.
(viii) To display minimum fees given by each membership type.

4. Queries Set 4 (Based on DML commands)


Write SQL commands for the following table MOVIE:

Table: MOVIE

NO TITLE TYPE RATING SEATSLEFT PRICE

1 SANJU BIOPIC A 4 250


2 RAID ACTION B 2 175
3 RACE3 ACTION C 7 245
4 HUNGAMA COMEDY A 3 130
5 BAHUBALI DRAMA A 3 300
6 AVENGER ACTION A 2 320
7 PARMANU THRILLER B 2 120
8 INCREDIBLES ANIMATION B 2 350
9 HITCHKI SOCIAL C 1 90
10 TITANIC ROMANTIC A 5 280

(i) Insert records as shown in the above table.


(ii) Display a report listing the movie number, current price, updated price for each movie in the
above table if the price is increased by 15%.
(iii) Delete a l the movies from the table with rating ‘C’.
(iv) Increase the price of all action movies by 5%. and thriller movies by 1%.
(v) Modify the price of the movie ‘Titanic’ to Rs 320.
(vi) Change the seats left for all action movies to 4.

5. Queries Set 5 (Based on Two Tables)


Write SQLqueries for the two tables given below:
Table: FLIGHTS
FNO SOURCE DEST NO_OF_FL NO_OF_STOP
IC301 MUMBAI BANGALORE 3 2
IC799 BANGALORE KOLKATA 8 3
MC101 DELHI VARANASI 6 0
IC302 MUMBAI KOCHI 1 4
AM812 LUCKNOW DELHI 4 0
MU499 DELHI CHENNAI 3 3

Table: FARES
FNO AIRLINES FARE TAX PERCENTAGE
IC301 Indian Airlines 9425 5
IC799 Spice Jet 8846 10
MC101 Deccan Airlines 4210 7
IC302 Jet Airways 13894 5
AM812 Indian Airlines 4500 6
MU499 Sahara 12000 4

(i) Display flight number & number of flights from Mumbai from the table FLIGHTS.
(ii) To display flight number, source, airlines of those flights where fare is less than Rs.
10000.
(iii) Increase the tax by 2% for the flights starting from Delhi.
(iv) Display the flight number and fare to be paid for the flights from Mumbai to Kochi
using the tables, FLIGHTS & FARES, where the fare to be paid = fare+fare*tax/100.
(v) Display total no of source stations(eliminate duplicate) present in the table.
(vi) To count total no of Indian Airlines flights starting from various cities.
(vii) Display the records of source stations starting with letter ‘B’.
(viii) Display total number of flights available for each Airlines.
(ix) Display the fare for the flight for MUMBAI to BANGLORE.
(x) Display flight number, number of flights and names of airlines that start from Delhi.

6. Queries Set 6 (Based on Two Tables)


Consider the tables given below :
Table : Faculty

TeacherId Name Address State PhoneNumber


T101 Savita Sharma A-151, Adarsh Delhi 991019564
Nagar
T102 Deepak Ghai K-5/52, Vikas Mumbai 893466448
Vihar
T103 MahaLakshmi D-6 Delhi 981166568
T104 Simi Arora Mumbai 658777564

Table : Course

Course Id Subject TeacherId Fee


C101 Introductory Mathematics T101 4500
C103 Physics T101 5000
C104 Introductory Computer Science T102 4000
C105 Advance Computer Science T104 6500

(i) To display CourseId, TeacherId, Name of Teacher, Phone Number of Teachers living in Delhi.
(ii) To display the total fees charged by each teacher for the various courses.
(iii) To display the details of the teacher who charges the lowest fees.
(iv) To display TeacherID, Names of Teachers, Subjects of all teachers with names of Teachers
starting with ‘S’.
(v) To display Subject Course ID, Teacher ID, Teacher Name and Phone Number of teachers whose
fees is more than 5000.
7. Queries and Outputs based on Single-row functions

(A) Write SQL commands for the following operations:

a) To display remainder of 175 and 5


b) To display cube of 24.
c) To display the number 563.854741 rounding off to the next hundred.
d) To find the square root of 625.
e) To convert ‘welcome’ into upper caseand FRIENDS into lower case.
f) To display ‘DIA’ from the word “MEDIA”.
g) To find the number of characters in Informatics Practices
h) To display the current date and time
i) To find the name of the weekday on 20th October, 2016.
j) To display today’s date into DD/MM/YYYY format.

(B ) Write the output of the following SQL queries:

(i) SELECT ROUND(6.5675, 2);


(ii) SELECT ROUND(4563.778,-3);
(iii) SELECT TRUNCATE(264.4367, -2);
(iv) SELECT TRUNCATE(8.975,2);
(v) SELECT SIGN(-25);
(vi) SELECT MID(‘HONESTY WINS’,3,4);
(vii) SELECT LEFT(‘WELCOME’,3);
(viii) SELECT RIGHT(CONCAT(‘PYTHON’,’PROGRAM’),9);
(ix) SELECT INSTR(‘UNICODE’,’CO’);
(x) SELECT DAYOFMONTH('2021-06-15');
(xi) SELECT DAYOFYEAR('2021-06-15');
(xii) SELECT DAY('2021-06-15');
(xiii) SELECT MONTHNAME('2021-06-15');
(xiv) SELECT CURDATE ();
(xv) SELECT SYSDATE();

(C ) Consider the following MOVIE table and write the SQL queries based on it.

Movie_ID MovieName Type ReleaseDate ProductionCost BusinessCost

M001 The Kashmir Files Action 2022/01/26 1245000 1300000

M002 Attack Action 2022/01/28 1120000 1250000

M003 Special 26 Thriller 2013/02/08 250000 300000

M004 Badhai ho Drama 2018/10/18 720000 68000

M005 Shabaash Mithu Biography 2022/02/04 110000 80000

M006 Spiderman Thriller 2021/12/16 24550000 34580000

(i) Write a query to display the movie name and movie type.
(ii) Write a query to display first four digits of production cost.
(iii) Write a query to display last four digits of business cost.
(iv) Write a query to display weekday of movie release dates.
(v) Write a query to display day name on which movies are going to be released.
8. Write a Python program to connect with a MySQL database and store records of 5 employees in a table
‘employee’ created in a database ‘company’. Also, extract records from the database table and display
them in a tabular format.

9. Write a MySQL connectivity program in Python to


(i) create a database SCHOOL.
(ii) create a table STUDENTS with the specifications - ROLLNO integer, NAME varchar(20),
GENDER character(1), PERCENTAGE decimal and perform the following operations:
a) insert records into the table
b) display the contents of the table

10. Write a program that integrates MySQL with Python to perform the following operations with
reference to the table STUDENTS created above:
(i) To sort the records according to names in ascending order.
(ii) To search a student using roll number. If present in the table, update the record with new
name, otherwise display an appropriate error message.
(iii) To search a student using roll number. If present in the table, delete the record, otherwise
display an appropriate error message.

11. Write a menu-driven Python program that defines and uses the following functions:
(i) function to check whether a number input from the user is a palindrome or not.
(ii) function to calculate the factorial of a number input from the user.
(iii) function to check if a number input from the user is prime or not.
(iv) function to print the Fibonacci series up to a limit n input from the user.
(v) function to check if a number input from the user is perfect or not.
(vi) function to check if a number input from the user is Armstrong or not.

12. Write a Python program that defines a function to count the number of alphabets and digits,
uppercase letters, lowercase letter, spaces and other characters in a string input from the user.

13. Write a Python program that defines a function sin(x,n) to calculate the value of sin(x) using its
Taylor series expansion up to n terms.

14. Write a menu-based Python program that uses functions to perform linear search, binary search,
bubble sort and insertion sort on a list of numbers.

15. Write a Python program that generates a series using a function while takes first and last values
of the series and then generates four terms that are equidistant e.g., if two number passed are 1
and 7.

16. Write a Python program that passes a dictionary and a list to a function to store the elements
of list as dictionary key and their frequency as dictionary value.

17. Write a Python program that passes a tuple NUMBERS to a function EvenSum to add those
values in the tuple which are even.

18. Write a program to count the total number of lines in a file and also count the total number of
lines starting with ‘H’, ‘R’, and ‘T’.
19. Write a Python program to read the contents of a text file line by line and display each word
separated by a $ symbol.

20. Write a Python program to read the contents of a text file and display the total number of
consonants, vowels, uppercase characters and lowercase characters present in the text file.

21. Write a Python program that uses Python’s pickle module to write records (roll number,
name, marks) into a binary file ‘student.dat’, also read records from that file and print them
on the screen. The program should perform the following operations using user-defined
functions:
a. search for any roll number and display the corresponding record if found,
otherwise the message “Roll number not found” should be displayed.
b. update the marks of the student whose roll number is input from the user.

22. Write a Python program to add records in a binary file ‘MARKS.DAT’ with the following
fields: rollno, name of student, marks of subject 1, marks of subject 2, marks of subject 3,
and sum of all subjects Read the created binary file ‘MARKS.DAT’ and show the contents
of file in the following format:
Roll No. Name Total Marks

23. Write a menu-based Python program to add, display, search, modify and delete records in
a binary file “emp” using dictionary and functions. Fields of employee file are :
empno : Empolyee
number name : Name of Employee
salary : Salary of Employee
bonus : 10% of salary.

24. Write a Python program to write content for fields - empno, empname, designation and salary
- to a .CSV file employee.csv. The program should then read the contents and display them
in the form of a list.

25. Write a Python program to read contents of a .CSV file employee.csv (with fields empno,
empname, designation and salary) and display them in a tabular form. Also display the total
number of records and sum of salaries of all employees.

26. Write a Python program to search records for given employee name from the CSV file
employee.csv containing fields empno, empname, designation and salary.

27. Write a menu-based Python program to implement a stack using a list.


28. Write a menu-based Python program to implement a stack for maintaining book details like
bcode, btitle and price. The program should contain functions to add, display and delete
book details.

29. Write a Python program that uses a stack to check whether a string is a palindrome or not.
30. Write a Python program that uses try-except block in Exception Handling to handle the built-in
exceptions ValueError, TypeError, and ZeroDivisionError.

You might also like