0% found this document useful (0 votes)
271 views5 pages

Class-12, List of Practicals (CS)

The document lists Python and SQL programs for a class XII Computer Science practical exam. It includes 23 Python programs covering topics like functions, recursion, sorting, searching, and data structures. It also includes 6 SQL programs involving creating tables, inserting/updating records, writing queries, and defining primary and foreign keys. The document provides the program number, brief description and page number for reference.

Uploaded by

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

Class-12, List of Practicals (CS)

The document lists Python and SQL programs for a class XII Computer Science practical exam. It includes 23 Python programs covering topics like functions, recursion, sorting, searching, and data structures. It also includes 6 SQL programs involving creating tables, inserting/updating records, writing queries, and defining primary and foreign keys. The document provides the program number, brief description and page number for reference.

Uploaded by

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

SRI GURU GOBIND SINGH COLLEGIATE PUBLIC SCHOOL

SECTOR-26, CHANDIGARH

LIST OF PRACTICALS FOR CLASS-XII (COMPUTER SCIENCE)

PYTHON PROGRAMS
S.No. Program Prog.No Page No.
.
1 WAP to input a number and print its cube. 1.1 9
2 WAP to print cubes of numbers in the range 15 to 20. 1.5 25
3 WAP that reads a line and prints its statistics. 2.1 50
4 WAP to create a dictionary containing names of competition winner students 2.2 68
as keys and number of their wins as values.
5 Given three lists as list1=[‘a’, ‘b’, ‘c’], list2=[‘h’, ‘i’, ‘t’] and list3=[‘0’, ‘1’, ‘2’]. 2.3 72
Write a program that adds lists 2 and 3 to list 1 as single element each. The
resultant list should be in the order of list 3, elements of list 1, list 2.
6 Given three lists as list1=[‘a’, ‘b’, ‘c’], list2=[‘h’, ‘i’, ‘t’] and list3=[‘0’, ‘1’, ‘2’]. 2.4 73
Write a program that adds individual elements of lists 2 and 3 to list 1. The
resultant list should be in the order of elements of list 3, elements of list 1,
elements of list 2.
7 Program to sort a list using Bubble sort. 2.8 75
8 Program to sort a sequence using insertion sort. 2.8 76
9 Program to add two numbers through a function. 3.1 101
10 Program to calculate simple interest using a function interest ( ) that can 3.2 110
receive principal amount, time and rate and returns calculated simple
interest. Do specify default values for rate and time as 10% and 2 years
respectively.
11 Program that receives two numbers in a function and returns the results of all 3.2 114
arithmetic operations (+, -, *, /, %) on these numbers.
12 WAP that inputs a main string and then creates an encrypted string by 4.2 166
embedding a short symbol based string after each character. The program
should also be able to produce the decrypted string from encrypted string.
13 WAP to display the size of a file in bytes. 5.1 198
14 WAP to display the number of lines in the file. 5.2 198
15 WAP to read a text file line by line and display each word separated by a ‘#’. 5.6 202
16 WAP to read a text file and display the count of vowels and consonants in the 5.7 203
file.
17 Write a recursive function to print a string backwards. 6.2 262
18 Program using a recursive function to print Fibonacci series upto nth term. 6.6 272
19 Binary Searching in an array (a sorted list). 6.7 274
20 Linear Searching in an array (linear list). 8.1 315
21 Binary Searching in an array. 8.2 317
22 Inserting an element in a sorted array using traditional algorithm. 8.3 320
23 Deletion of an element from a sorted linear list. 8.5 323
24 Traversing a linear list. 8.6 325
25 Python program to implement stack operations. 9.1 352
26 Program to implement Queue operations. 9.2 365
SQL PROGRAMS
S.No. Program Ques.No. Page No.
1 Mr. Singh is responsible for setting up an inventory system in a supermarket. 19 558
He creates a database table, INVENTORY, to store the information on
products for sale.
Table : INVENTORY
CAT CODE NAME PRICE QTY
(Category) (Product (Product Name) (Price of Product) (Number of
Code) items in
stock)
Beverage B163 BEST juice 10.0 10
Snack S968 YUMMY 12.2 40
Noodle N042 WOW 20.2 20
Beverage B482 FRESH tea 25.9 80
noodle N091 QQ noodle 8.4 50

(a) Which field CAT, CODE, NAME, PRICE or QTY, should be used as a key
field?
(b) The data type of QTY is integer, Judy, Mr. Singh’s colleague, suggests
changing it to real number or string. Mr. Singh disagrees with Judy’s
suggestion. Why?
(c) Mr. Singh write the following SQL command. Based on the five given
records in INVENTORY above. What is the query result?
Select CODE, PRICE from INVENTORY where PRICE > 10 and QTY < 40

2 Create table Employee with the following structure: Ex-13.1 574


Name of ID First_Nam Last_Name User_ID Salary
Column e
Type Number Varchar Varchar Varchar Number
(4) (30) (30) (10) (9,2)

Ensure the following specification in created table:


 ID should be declared as Primary Key.
 User_ID should be unique.
 Salary must be greater than 5000.
 First_Name & Last_Name must ne remain blank.

3 An examination agent designs the following database tables to store the 13 587
information on candidates who register for examination.
Table : CAND
Field Name Type Width Description
CNUM Character 8 Unique candidate number of the
candidate where the first three
characters are the unique school code
of the candidate’s school
CNAME Character 30 Name of the candidate
DOB Date Date of birth of the candidate
Table : REGISTER
Field Name Type Width Description
CNUM Character 8 Candidate number of the candidate
who sits the examination of the
subject
SCODE Character 2 Unique subject code

Table : SUBJECT
Field Name Type Width Description
SCODE Character 2 Unique subject code
SNAME Character 30 Name of the subject

(a) (i) Write an SQL command to create CAND.


(ii) Which of the following can be a candidate key of CAND? Explain
briefly.
(A) CNUM
(B) CNAME + DOB
(b) Identify the primary key(s) and foreign key(s) of REGISTER.
(c) (i) Write an SQL command to increase the width of CNUM in CAND to
12.
(ii) The subject code and subject name of a new subject are 09 and
LAW respectively. Write a SQL command to insert this record into
SUBJECT.

4 Given a statement as follows:- 17 590


CREATE TABLE Orders
( O_Id int NOT NULL,
OrderNo int NOT NULL,
P_Id int,
PRIMARY KEY (O_Id),
FOREIGN KEY (P_Id) REFERENCES Persons (P_Id) );
Identify the number and types of constraints in the table Orders;

5 Write a output for SQL queries (i) to (iii), which are based on the Table: 18 607
STUDENT given below:
Table : STUDENT
RollN Name Clas DOB Gender City Marks
o s
1 Nanda X 06-06-1995 M Agra 551
2 Saurabh XII 07-05-1993 M Mumbai 462
3 Sanal XI 06-05-1994 F Delhi 400
4 Trisla XII 08-08-1995 F Mumbai 450
5 Stort XII 08-10-1995 M Delhi 369
6 Marisla XI 12-12-1994 F Dubai 250
7 Neha X 08-12-1995 F Moscow 377
8 Nishant X 12-06-1995 M Moscow 489
I. SELECT COUNT(*), City FROM STUDENT
GROUP BY CITY HAVING COUNT (*) > 1;
II. SELECT MAX (DOB), MIN (DOB), FROM STUDENT;
III. SELECT NAME, GENDER FROM STUDENT WHERE CITY = “ Delhi”;

6 Given the following student relation: 20 608

RELATION STUDENT
No. Name Age Department Dateofadm Fee Sex
1 Pankaj 24 Computer 10/01/97 120 M
2 Shalini 21 History 24/03/98 200 F
3 Sanjay 22 Hindi 12/12/96 300 M
4 Sudha 25 History 01/07/99 400 F
5 Rakesh 22 Hindi 05/09/97 250 M
6 Shakeel 30 History 27/06/98 300 M
7 Surya 34 Computer 25/02/97 210 M
8 Shikha 23 Hindi 31/07/97 200 F

Write SQL commands for (a) to (f) and write output for (g).
(a) To show all information about the students of History department.
(b) To list the names of female students who are in Hindi department.
(c) To list names of all students with their date of admission in ascending
order.
(d) To display student’s Name, Fee, Age for male Students only.
(e) To count the number of student with Age < 23.
(f) To insert a new row in the STUDENT table with the following data:
9, “Zaheer”, 36, “Computer”, {12/03/97}, 230, “M”
(g) Give the output of following SQL statements:
I. Select COUNT (distinct department) from STUDENT;
II. Select MAX (Age) from STUDENT where Sex=”F”;
III. Select AVG (Fee) from STUDENT where Dateofadm <
{01/01/98}.
IV. Select SUM (Fee) from STUDENT where Dateofadm <
{01/01/98}.

7 Consider the following DEPT and WORKER tables. Write SQL queries for (i) to 22 610
and (iv). Find outputs for SQL queries(v) to (viii).

Table : DEPT
DCODE DEPARTMENT CITY
D01 MEDIA DELHI
D02 MARKETING DELHI
D03 INFRASTRUCTURE MUMBAI
D05 FINANCE KOLKATA
D04 HUMAN RESOURCE MUMBAI
Table : WORKER
WNO NAME DOJ DOB GENDER DCODE
1001 George K 2013-09-02 1991-09-01 MALE D01
1002 Ryma Sen 2012-12-11 1990-12-15 FEMALE D03
1003 Mohitesh 2013-02-03 1987-09-04 MALE D05
1007 Anil Jha 2014-01-17 1984-10-19 MALE D04
1004 Manila Sahai 2012-12-09 1986-11-14 FEMALE D01
1005 R Sahay 2013-11-18 1987-03-31 MALE D02
1006 Jaya Priya 2014-06-09 1985-06-23 FEMALE D05

NOTE:- DOJ refers to date of joining and DOB refers to date of birth of
workers.
I. To display WNo, Name, Gender from the table WORKER in descending
order of Wno.
II. To display the Name of all the FEMALE workers from the table
WORKER.
III. To display the Wno and Name of those workers from the table
WORKER who are born between ‘1987-01-01’ and ‘1991-12-01’.
IV. To count and display MALE workers who have joined after ‘1986-01-
01’.
V. SELECT COUNT (*), DCODE FROM WORKER
GROUP BY DCODE HAVING COUNT (*) > 1;
VI. SELECT DISTINCT DEPARTMENT FROM DEPT;
VII. SELECT NAME, DEPARTMENT, CITY FROM WORKER W, DEPT D WHERE
W.DCODE = D.DCODE AND WNO < 1003;
VIII. SELECT MAX (DOJ), MIN (DOB) FROM WORKER;

PROJECT
 The aim of the class project is to create something that is tangible and useful. This should be done in groups of 2
to 3 students (or individual). The aim here is to find a real world problem that is worthwhile to solve. Students
are encouraged to visit local businesses and ask them about the problems that they are facing. For example, if a
business is finding it hard to create invoices for filing GST claims, then students can do a project that takes the
raw data (list of transactions), groups the transactions by category, accounts for the GST tax rates and creates
invoices in the appropriate format. Students can be extremely creative here. They can use a wide variety of
Python libraries to create user friendly applications such as games, software for their school, software for their
disabled fellow students, and mobile applications. Of course to do some of this projects some additional learning
is required; this should be encouraged. Students should know how to teach themselves.

You might also like