Xii - Computer Science (083) Ncert - Questions: Number Content Number
Xii - Computer Science (083) Ncert - Questions: Number Content Number
NCERT - QUESTIONS
CHAPTER PAGE
CONTENT
NUMBER NUMBER
1 1
2 2
3 3
4 4
5 5
6 6
7 8
8 10
9 14
10 18
11 19
12 19
13 20
1. “Every syntax error is an exception but every exception cannot be a syntax error.”
Justify the statement.
2. When are the following built-in exceptions raised? Give examples to support your
answers.
a. ImportError b. IOError c. NameError d. ZeroDivisionError
3. What is the use of a raise statement? Write a code to accept two numbers and display
the quotient. Appropriate exception should be raised if the user enters the second
number (denominator) as zero (0).
4. Use assert statement in Question No. 3 to test the division expression in the program.
5. Define the following:
a. Exception Handling b. Throwing an exception c. Catching an exception
6. Explain catching exceptions using try and except block.
7. Consider the code given below and fill in the blanks.
try:
quotient=(num1/num2)
else:
print(" Great .. you are a good programmer")
8. Write a python program to check whether the given string is palindrome or not, using
deque. (Hint : refer to algorithm 4.1)
1. Consider a list of 10 elements:
numList = [7,11,3,10,17,23,1,4,21,5].
Display the partially sorted list after three complete passes of Bubble sort.
2. Identify the number of swaps required for sorting the following list using selection sort
and bubble sort and identify which is the better sorting technique with respect to the
number of comparisons.
List 1: 63 42 21 9
3. Consider the following lists:
List 1: 2 3 5 7 11
List 2: 11 7 5 3 2
If the lists are sorted using Insertion sort then which of the lists List1 or List 2 will
make the minimum number of comparisons? Justify using diagrammatic
representation.
4. Write a program using user defined functions that accepts a List of numbers as an
argument and finds its median. (Hint : Use bubble sort to sort the accepted list. If there
are odd number of terms, the median is the center term. If there are even number of
terms, add the two middle terms and divide by 2 get median)
5. All the branches of XYZ school conducted an aptitude test for all the students in the
age group 14 - 16. There were a total of n students. The marks of n students are stored
in a list. Write a program using a user defined function that accepts a list of marks as
an argument and calculates the ‘xth’ percentile (where x is any number between 0 and
100).You are required to perform the following steps to be able to calculate the ‘xth’
percentile.
Note: Percentile is a measure of relative performance i.e. It is calculated based on a candidate’s performance
with respect to others. For example : If a candidate's score is in the 90 th percentile, that means she/he
scored better than 90% of people who took the test.
Steps to calculate the xth percentile:
I. Order all the values in the data set from smallest to largest using Selection Sort. In
general any of the sorting methods can be used.
II. Calculate index by multiplying x percent by the total number of values, n.
For example: to find 90th percentile for 120 students: 0.90*120 = 108
[50, 31, 21, 28, 72, 41, 73, 93, 68, 43, 45, 78, 5,
17, 97, 71, 69, 61, 88, 75, 99, 44, 55,9]
Use linear search to determine the position of 1, 5, 55 and 99 in the list. Also note
the number of key comparisons required to find each of these numbers in the list.
Use a Python function to sort/arrange the list in ascending order.
Again, use linear search to determine the position of 1, 5, 55 and 99 in the list and
note the number of key comparisons required to find these numbers in the list.
Use binary search to determine the position of 1, 5, 55 and 99 in the sorted list.
Record the number of iterations required in each case.
6. Write a program that takes as input the following unsorted list of English words:
[Perfect, Stupendous, Wondrous, Gorgeous, Awesome, Mirthful, Fabulous,
Splendid, Incredible, Outstanding, Propitious, Remarkable, Stellar,
Unbelievable, Super, Amazing].
Use linear search to find the position of Amazing, Perfect, Great and
Wondrous in the list. Also note the number of key comparisons required to find
these words in the list.
Use a Python function to sort the list.
Again, use linear search to determine the position of Amazing, Perfect, Great
and Wondrous in the list and note the number of key comparisons required to
find these words in the list.
Use binary search to determine the position of Amazing, Perfect, Great and
Wondrous in the sorted list. Record the number of iterations required in each
case.
7. Estimate the number of key comparisons required in binary search and linear search
if we need to find the details of a person in a sorted database having 230
(1,073,741,824) records when details of the person being searched lies at the middle
position in the database. What do you interpret from your findings?
8. Use the hash function: h(element)= element%11 to store the collection of numbers:
[44, 121, 55, 33, 110, 77, 22, 66] in a hash table. Display the hash table
created. Search if the values 11, 44, 88 and 121 are present in the hash table, and
display the search results.
9. Write a Python program by considering a mapping of list of countries and their capital
cities such as:
CountryCapital= {'India':'New Delhi','UK': 'London','France':'Paris',
'Switzerland': 'Berne', 'Australia': 'Canberra'}
Let us presume that our hash function is the length of the Country Name. Take two
lists of appropriate size: one for keys (Country) and one for values (Capital). To put an
element in the hash table, compute its hash code by counting the number of characters
in Country, then put the key and value in both the lists at the corresponding indices.
For example, India has a hash code of 5. So, we store India at the 5th position (index
4) in the keys list, and New Delhi at the 5th position (index 4) in the values list and so
on. So that we end up with:
Hash index = length
List of Keys List of Values
of key – 1
0 None None
1 UK Londan
2 None None
3 Cuba Havana
4 India New Delhi
5 France Paris
6 None None
7 None None
8 Australia Canberra
9 None None
10 Switzerland Berne
Now search the capital of India, France and the USA in the hash table and display your
result.
6. A school teacher wants to analyse results. Identify the appropriate statistical technique
to be used along with its justification for the following cases:
Teacher wants to compare performance in terms of division secured by students in
Class XII A and Class XII B where each class strength is same.
Teacher has conducted five unit tests for that class in months July to November
and wants to compare the class performance in these five months.
7. Suppose annual day of your school is to be celebrated. The school has decided to
felicitate those parents of the students studying in classes XI and XII, who are the
alumni of the same school. In this context, answer the following questions:
Which statistical technique should be used to find out the number of students
whose both parents are alumni of this school?
How varied are the age of parents of the students of that school?
8. For the annual day celebrations, the teacher is looking for an anchor in a class of 42
students. The teacher would make selection of an anchor on the basis of singing skill,
writing skill, as well as monitoring skill.
Which mode of data collection should be used?
How would you represent the skill of students as data?
9. Differentiate between structured and unstructured data giving one example.
The principal of a school wants to do following analysis on the basis of food items
procured and sold in the canteen:
Compare the purchase and sale price of fruit juice and biscuits.
Compare sales of fruit juice, biscuits and samosa.
Variation in sale price of fruit juices of different companies for same quantity
(in ml).
Create an appropriate dataset for these items (fruit juice, biscuits, samosa) by
listing their purchase price and sale price. Apply basic statistical techniques to
make the comparisons.
1. Give the terms for each of the following:
a. Collection of logically related records.
b. DBMS creates a file that contains description about the data
stored in the database.
c. Attribute that can uniquely identify the tuples in a relation.
d. Special value that is stored when actual data value is unknown
for an attribute.
e. An attribute which can uniquely identify tuples of the table but is not
defined as primary key of the table.
f. Software that is used to create, manipulate and maintain a relational database.
2. Why foreign keys are allowed to have NULL values? Explain with an example.
3. Differentiate between:
a. Database state and database schema
b. Primary key and foreign key
c. Degree and cardinality of a relation
4. Compared to a file system, how does a database management system avoid redundancy
in data through a database?
5. What are the limitations of file system that can be overcome by a relational DBMS?
6. A school has a rule that each student must participate in a sports activity. So each one
should give only one preference for sports activity. Suppose there are five students in
a class, each having a unique roll number. The class representative has prepared a list
of sports preferences as shown below. Answer the following:
Table: Sports Preferences
Roll_No Preference
9 Cricket
13 Football
17 Badminton
17 Football
21 Hockey
24 NULL
NULL Kabadi
a. Roll no 24 may not be interested in sports. Can a NULL value be assigned to that
student’s preference field?
b. Roll no 17 has given two preferences sports. Which property of relational DBMC
is violated here? Can we use any constraint or key in the relational DBMS to
check against such violation, if any?
c. Kabaddi was not chosen by any student. Is it possible to have this tuple
in the Sports Preferences relation?
7. In another class having 2 sections, the two respective class representatives
have prepared 2 separate Sports Preferences tables, as shown below:
Sports preference of section 1 (arranged on roll number column)
Table: Sports Preferences
Roll_No Sports
9 Cricket
13 Football
17 Badminton
21 Hockey
24 Cricket
Sports preference of section 2 (arranged on Sports name column, and column order is
also different)
Table: Sports Preferences
Sports Roll_No
Badminton 17
Cricket 9
Cricket 24
Football 13
Hockey 21
Are the states of both the relations equivalent? Justify.
8. The school canteen wants to maintain records of items available in the school canteen
and generate bills when students purchase any item from the canteen. The school
wants to create a canteen database to keep track of items in the canteen and the items
purchased by students. Design a database by answering the following questions:
a. To store each item name along with its price, what relation should be used?
Decide appropriate attribute names along with their data type. Each item and
its price should be stored only once. What restriction should be used while
defining the relation?
b. In order to generate bill, we should know the quantity of an item purchased.
Should this information be in a new relation or a part of the previous relation?
If a new relation is required, decide appropriate name and data type for
attributes. Also, identify appropriate primary key and foreign key so that the
following two restrictions are satisfied:
i. The same bill cannot be generated for different orders.
ii. Bill can be generated only for available items in the canteen.
c. The school wants to find out how many calories students intake when they order
an item. In which relation should the attribute ‘calories’ be stored?
9. An organisation wants to create a database EMP-DEPENDENT to maintain following
details about its employees and their dependent.
EMPLOYEE(AadharNumber, Name, Address, Department,EmployeeID)
DEPENDENT(EmployeeID, DependentName, Relationship)
a. Name the attributes of EMPLOYEE, which can be used as candidate keys.
b. The company wants to retrieve details of dependent of a particular employee.
Name the tables and the key which are required to retrieve this detail.
c. What is the degree of EMPLOYEE and DEPENDENT relation?
10. School uniform is available at M/s Sheetal Private Limited. They have maintained
SCHOOL_UNIFORM Database with two relations viz. UNIFORM and COST. The
following figure shows database schema and its state.
School Uniform Database
iii) To display the name of the month in which you were born.
iv) To display your name in capital letters.
2. Write the output produced by the following SQL statements:
i) SELECT POW(2,3);
ii) SELECT ROUND(342.9234,-1);
iii) SELECT LENGTH("Informatics Practices");
iv) SELECT YEAR(“1979/11/26”), MONTH(“1979/11/26”),
DAY(“1979/11/26”), MONTHNAME(“1979/11/26”);
v) SELECT LEFT("INDIA",3), RIGHT("Computer Science",4),
MID("Informatics",3,4), SUBSTR("Practices",3);
3. Consider the following MOVIE table and write the SQL queries based on it.
MovieID MovieName Category ReleseDate ProductionCost BusinessCost
001 Hindi_Movie Musical 2018-04-23 1,24,500 1,30,000
002 Tamil_Movie Acion 2016-05-17 1,12,000 1,18,000
003 English_Movie Horror 2017-08-06 2,45,000 3,60,000
004 Bengali_Movie Adventure 2017-01-04 72,000 1,00,000
005 Telugu_Mpvie Action - 1,00,000 -
006 Punjabi_Movie Comedy - 30,500 -
a. Display all the information from the Movie table.
b. List business done by the movies showing only MovieID, MovieName and
Total_Earning. Total_ Earning to be calculated as the sum of ProductionCost and
BusinessCost.
c. List the different categories of movies.
d. Find the net profit of each movie showing its MovieID, MovieName and NetProfit.
*Net Profit is to be calculated as the difference between Business Cost and Production Cost.
e. List MovieID, MovieName and Cost for all movies with ProductionCost greater
than 10,000 and less than 1,00,000.
f. List details of all movies which fall in the category of comedy or action.
g. List details of all movies which have not been released yet.
4. 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:
i. It should have a column TeamID for storing an integer value between 1 to
9, which refers to unique identification of a team.
ii. Each TeamID should have its associated name (TeamName), which should
be a string of length not less than 10 characters.
c. Using table level constraint, make TeamID as the primary key.
d. Show the structure of the table TEAM using a SQL statement.
e. As per the preferences of the students four teams were formed as given below.
Insert these four rows in TEAM table:
Row 1: (1, Team Titan)
Row 2: (2, Team Rockers)
Row 3: (3, Team Magnet)
Row 3: (4, Team Hurricane)
f. Show the contents of the table TEAM using a DML statement.
g. Now create another table MATCH_DETAILS and insert data as shown below.
Choose appropriate data types and constraints for each attribute.
MatchID MatchDate FirstTeamID SecondTeamID FirstTeamScore SecondTeamScore
M1 2018-07-17 1 2 90 86
M2 2018-07-18 3 4 45 48
M3 2018-07-19 1 3 78 56
M4 2018-07-19 2 4 56 67
M5 2018-07-18 1 4 32 87
M6 2018-07-17 2 3 67 51
5. Using the sports database containing two relations (TEAM, MATCH_DETAILS) and
write the queries for the following:
a. Display the MatchID of all those matches where both the teams have scored more than
70.
b. Display the MatchID of all those matches where FirstTeam has scored less than 70 but
SecondTeam has scored more than 70.
c. Display the MatchID and date of matches played by Team 1 and won by it.
d. Display the MatchID of matches played by Team 2 and not won by it.
Change the name of the relation TEAM to T_DATA. Also change the attributes TeamID
and TeamName to T_ID and T_NAME respectively.
6. A shop called Wonderful Garments who sells school uniforms maintains a database
SCHOOLUNIFORM as shown below. It consisted of two relations - UNIFORM and
COST. They made UniformCode as the primary key for UNIFORM relations. Further,
they used UniformCode and Size to be composite keys for COSTrelation. By analysing
the database schema and database state, specify SQL queries to rectify the following
anomalies.
a. M/S Wonderful Garments also keeps handkerchiefs of red colour, medium size
of Rs. 100 each.
b. INSERT INTO COST (UCode, Size, Price) values (7, 'M',100);
When the above query is used to insert data, the values for the
handkerchief without entering its details in the UNIFORM relation is
entered. Make a provision so that the data can be entered in the COST
table only if it is already there in the UNIFORM table.
c. Further, they should be able to assign a new UCode to an item only if it has a
valid UName. Write a query to add appropriate constraints to the
SCHOOLUNIFORM database.
d. Add the constraint so that the price of an item is always greater than zero.
7. Consider the following table named “Product”, showing details of products being sold
in a grocery shop.
PCode PName UPrice Manufacturer
P01 Washing Powder 120 Sufr
P02 Toothpaste 54 Colgate
P03 Soap 25 Lux
P04 Toothpaste 65 Pepsodent
P05 Soap 35 Dove
P06 Shampoo 245 Dove
Write SQL queries for the following:
a. Create the table Product with appropriate data types and constraints.
b. Identify the primary key in Product.
c. List the Product Code, Product name and price in descending order of their product
name. If PName is the same, then display the data in ascending order of price.
d. Add a new column Discount to the table Product.
e. Calculate the value of the discount in the table Product as 10 per cent of the UPrice for
all those products where the UPrice is more than 100, otherwise the discount will be
0.
f. Increase the price by 12 per cent for all the products manufactured by Dove.
g. Display the total number of products manufactured by each manufacturer.
a. Write the output(s) produced by executing the following queries on the basis of
the information given above in the table Product:
1. What is data communication? What are the main components of data communication?
2. Which communication mode allows communication in both directions simultaneously?
3. Among LAN, MAN, and WAN, which has the highest speed and which one can cover
the largest area?
4. What are three categories of wired media? Explain them.
5. Compare wired and wireless media.
6. Which transmission media carries signals in the form of light?
7. List out the advantages and disadvantages of optical fiber cable.
8. What is the range of frequency for radio waves?
9. 18 Gbps is equal to how many Bits per second?
10. HTTP stands for?
11. Write short note on the following:
HTTP Bandwidth Bluetooth DNS Data transfer rate
12. What is protocol in data communication? Explain with an example.
13. A composite signal contains frequencies between 500 MHz and 1GHz.
What is the bandwidth of a signal?
Description
A new restaurant “Stay Healthy” is coming up in your locality. The owner/management of
the restaurant wants to use a computer to generate bills and maintain other records of the
restaurant. Your team is asked to develop an application software to automate the order
placing and associated processes.
Specifications
Make a group of students to undertake a project on automating the order processing of the
restaurant ‘Stay Healthy’. The owner of the restaurant wants the following specific
functionalities to be made available in the developed application:
There should be two types of Login options — one for the manager of the joint and
other for the customer.
Kiosk(s) running the software for customers will be placed at reception for
placing the order. On the opening screen, menu for placing orders will be displayed.
To place orders, customers will enter Item Code(s) and quantity desired.
After placing an order, a soft copy of the bill will be displayed on the kiosk,
and order number of the day) and should be saved in the data file/database.
For Manager login—provision for entry/change of Menu, deletion of Order (on demand)
and generation of following report is desired.
A Report giving Summary of the Sales made on a Day.
Program should accept the date for which the Summary is required.
Add at least one more relevant report of your choice to the program.
*****************************************************************************************************
Project Title 2: Development of a Puzzle
Description
Implement a puzzle solving game in Python. The game presents a grid board composed of
cells to the player, in which some cells have Bomb. Player is required to clear the board (of
the bomb), without detonating any one of them with the help of clue(s) provided on the board.
Specifications
For clearing the board, the player will click a cell on the board, if the cell contains a
bomb, the game finishes. If the cell does not contain a bomb, then the cell reveals a
number giving a clue about the number of bombs hidden in adjacent cells.
Before you start coding the game, play any Minesweeper game five times. This will help
you in proper understanding of your project. To reduce the complexity of the program
you can fix the grid size to 6x6 and number of bombs to 6.
Note: Do ensure to handle various exception(s) which may occur while playing the game, in
your code.
******************************************************************************************************
Project Title 3: Development of an Educational Game
Description
You are a member of the ICT club of your school. As a club member, you are given the
responsibility of identifying ways to improve mathematical skills of kids, in the age group of
5-7 years. One of the club members suggested developing an Edutainment Game named
“Match the Sum” for it. Match the Sum will hone summing skills of student(s), by allowing
them to form number 10 by adding 2/3 digits.
Specifications
Following are the details of provisions required for program:
Display a list of 15 cells on screen, where each cell can hold a digit (1 to 9)
Randomly generate a digit at a time and place it in the list from the right end.
Program will keep on generating digits at equal intervals of time and place it in
the rightmost cell. (Already existing digits, will be shifted left, by one cell, with
every new addition of digits’ in the list)
For playing the game, students’ will be allowed to type 2/3 digits (one at a time)
currently displayed in the list of cells.
If the sum of those digits is 10, then those digits should get removed from the
list of cells.
Game will continue till there is an empty cell to insert a digit in the list of cells.
Note: Do take care of the situation when digits displayed in a list of cells do not add up to
10.