0% found this document useful (0 votes)
19 views37 pages

Class XI Computer Science Syllabus 2025-26

The document outlines the curriculum for Computer Science for Class XI and XII for the academic year 2025-26, detailing learning outcomes, unit distribution of marks, and syllabus content. It covers topics such as computational thinking, programming, computer networks, database management, and ethical considerations in technology. Practical components include Python programming, SQL queries, and projects that integrate learned concepts.

Uploaded by

ashwinkumar9355
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)
19 views37 pages

Class XI Computer Science Syllabus 2025-26

The document outlines the curriculum for Computer Science for Class XI and XII for the academic year 2025-26, detailing learning outcomes, unit distribution of marks, and syllabus content. It covers topics such as computational thinking, programming, computer networks, database management, and ethical considerations in technology. Practical components include Python programming, SQL queries, and projects that integrate learned concepts.

Uploaded by

ashwinkumar9355
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

COMPUTER SCIENCE

Subject Code - 083


Class XI (2025-26)

1. Learning Outcomes

Students should be able to:


a) develop basic computational thinking
b) explain and use data types
c) appreciate the notion of algorithms
d) develop a basic understanding of computer systems- architecture and
operating system
e) explain cyber ethics, cyber safety, and cybercrime
f) understand the value of technology in societies along with consideration of
gender and disability issues.

2. Distribution of Marks

Unit No. Unit Name Marks

Computer Systems and Organisation


1 10

Computational Thinking and Programming -1


2 45

3 Society, Law, and Ethics 15

Total 70

3. Unit wise Syllabus

Unit 1: Computer Systems and Organisation

● Basic computer organisation: Introduction to Computer System, hardware,


software, input device, output device, CPU, memory (primary, cache and
secondary), units of memory (bit, byte, KB, MB, GB, TB, PB)
● Types of software: System software (Operating systems, system utilities, device
drivers), programming tools and language translators (assembler, compiler, and
interpreter), application software
● Operating System(OS): functions of the operating system, OS user interface
● Boolean logic: NOT, AND, OR, NAND, NOR, XOR, truth tables and De
Morgan’s laws, Logic circuits
● Number System: Binary, Octal, Decimal and Hexadecimal number system;
conversion between number systems
● Encoding Schemes: ASCII, ISCII, and Unicode (UTF8, UTF32)
Unit 2: Computational Thinking and Programming - I

● Introduction to Problem-solving: Steps for Problem-solving (Analyzing the problem,


developing an algorithm, coding, testing, and debugging), representation of
algorithms using flowchart and pseudocode, decomposition
● Familiarization with the basics of Python programming: Introduction to Python,
Features of Python, executing a simple “hello world" program, execution modes:
interactive mode and script mode, Python character set, Python tokens( keyword,
identifier, literal, operator, punctuator), variables, concept of l-value and r-value, use
of comments
● Knowledge of data types: Number(integer, floating point,complex), boolean,
sequence(string, list, tuple), None, Mapping(dictionary), mutable and immutable
data types.
● Operators: arithmetic operators, relational operators, logical operators, assignment
operators, augmented assignment operators, identity operators (is, is not),
membership operators (in not in)
● Expressions, statement, type conversion, and input/output: precedence of
operators, expression, evaluation of an expression, type-conversion (explicit and
implicit conversion), accepting data as input from the console and displaying output.
● Errors- syntax errors, logical errors, and run-time errors
● Flow of Control: introduction, use of indentation, sequential flow, conditional and
iterative flow
● Conditional statements: if, if-else, if-elif-else, flowcharts, simple programs: e.g.:
absolute value, sort 3 numbers and divisibility of a number.
● Iterative Statement: for loop, range(), while loop, flowcharts, break and continue
statements, nested loops, suggested programs: generating pattern, summation of
series, finding the factorial of a positive number, etc.
● Strings: introduction, string operations (concatenation, repetition, membership and
slicing), traversing a string using loops, built-in functions/methods–len(),
capitalize(), title(), lower(), upper(), count(), find(), index(), endswith(), startswith(),
isalnum(), isalpha(), isdigit(), islower(), isupper(), isspace(),lstrip(), rstrip(), strip(),
replace(), join(), partition(), split()
● Lists: introduction, indexing, list operations (concatenation, repetition, membership
and slicing), traversing a list using loops, built-in functions/methods–len(), list(),
append(), extend(), insert(), count(), index(), remove(), pop(), reverse(), sort(),
sorted(), min(), max(), sum(); nested lists, suggested programs: finding the
maximum, minimum, mean of numeric values stored in a list; linear search on list
of numbers and counting the frequency of elements in a list.
● Tuples: introduction, indexing, tuple operations (concatenation, repetition,
membership and slicing); built-in functions/methods – len(), tuple(), count(),
index(), sorted(), min(), max(), sum(); tuple assignment, nested tuple; suggested
programs: finding the minimum, maximum, mean of values stored in a tuple; linear
search on a tuple of numbers, counting the frequency of elements in a tuple.
● Dictionary: introduction, accessing items in a dictionary using keys, mutability of a
dictionary (adding a new term, modifying an existing item), traversing a dictionary,
built-in functions/methods – len(), dict(), keys(), values(), items(), get(), update(),
del, clear(), fromkeys(), copy(), pop(), popitem(), setdefault(), max(), min(),
sorted(); Suggested programs: count the number of times a character appears in a
given string using a dictionary, create a dictionary with names of employees, their
salary and access them.
● Introduction to Python modules: Importing module using ‘import <module>’ and
using from statement, importing math module (pi, e, sqrt(), ceil(), floor(), pow(),
fabs(), sin(), cos(), tan()); random module (random(), randint(), randrange()),
statistics module (mean(), median(), mode()).

Unit 3: Society, Law and Ethics

● Digital Footprints
● Digital Society and Netizen: net etiquettes, communication etiquettes, social media
etiquettes
● Data Protection: Intellectual property rights (copyright, patent, trademark), violation
of IPR (plagiarism, copyright infringement, trademark infringement), open source
software and licensing (Creative Commons, GPL and Apache)
● Cyber Crime: definition, hacking, eavesdropping, phishing and fraud emails,
ransomware, cyber trolls, cyber bullying
● Cyber safety: safely browsing the web, identity protection, confidentiality
● Malware: viruses, trojans, adware
● E-waste management: proper disposal of used electronic gadgets.
● Information Technology Act (IT Act)
● Technology and society: Gender and disability issues while teaching and using
computers

4. Practical

[Link]. Unit Name Marks (Total=30)


1. Lab Test (12 marks)
Python program (60% logic + 20% documentation + 12
20% code quality)
2. Report File + Viva (10 marks)
Report file: Minimum 20 Python programs 7
Viva voce 3
3. Project (that uses most of the concepts that have been 8
learnt)
5. Suggested Practical List

Python Programming

● Input a welcome message and display it.


● Input two numbers and display the larger / smaller number.
● Input three numbers and display the largest / smallest number.
● Generate the following patterns using nested loops:
Pattern-1 Pattern-2 Pattern-3

* 12345 A
** 1234 AB
*** 123 ABC
**** 12 ABCD
***** 1 ABCDE
● Write a program to input the value of x and n and print the sum of the following
series:
⮚ 1 + 𝑥 + 𝑥2 + 𝑥3 + 𝑥4 + ⋯ 𝑥n

⮚ 1 − 𝑥 + 𝑥2 − 𝑥3 + 𝑥4 − ⋯ 𝑥n
⮚ x2 x3 x4 xn
𝑥+ + + +⋯
2 3 4 n
⮚ x2 x3 x4 xn
𝑥+ + + +⋯
2! 3! 4! n!

● Determine whether a number is a perfect number, an Armstrong number or a


palindrome.
● Input a number and check if the number is a prime or composite number.
● Display the terms of a Fibonacci series.
● Compute the greatest common divisor and least common multiple of two integers.
● Count and display the number of vowels, consonants, uppercase, lowercase
characters in string.
● Input a string and determine whether it is a palindrome or not; convert the case of
characters in a string.
● Find the largest/smallest number in a list/tuple
● Input a list of numbers and swap elements at the even location with the elements at
the odd location.
● Input a list/tuple of elements, search for a given element in the list/tuple.
● Create a dictionary with the roll number, name and marks of n students in a class
and display the names of students who have marks above 75.
6. Suggested Reading Material
● NCERT Textbook for Computer Science (Class XI)
● Support Material on CBSE website
COMPUTER SCIENCE
Subject Code – 083
Class XII (2025-26)

1. Prerequisites
Computer Science- Class XI

2. Learning Outcomes

Student should be able to


a) apply the concept of function.
b) explain and use the concept of file handling.
c) use basic data structure: Stacks
d) explain basics of computer networks.
e) use Database concepts, SQL along with connectivity between Python and SQL.

3. Distribution of Marks:

Unit No. Unit Name Marks

Computational Thinking and


1 40
Programming – 2

2 Computer Networks 10

3 Database Management 20

Total 70

4. Unit wise Syllabus


Unit 1: Computational Thinking and Programming – 2
● Revision of Python topics covered in Class XI.
● Functions: types of function (built-in functions, functions defined in module, user
defined functions), creating user defined function, arguments and parameters,
default parameters, positional parameters, function returning value(s), flow of
execution, scope of a variable (global scope, local scope)
● Exception Handling: Introduction, handling exceptions using try-except-finally
blocks
● Introduction to files, types of files (Text file, Binary file, CSV file), relative
and absolute paths
● Text file: opening a text file, text file open modes (r, r+, w, w+, a, a+), closing a text
file, opening a file using with clause, writing/appending data to a text file using
write() and writelines(), reading from a text file using read(), readline() and
readlines(), seek and tell methods, manipulation of data in a text file
● Binary file: basic operations on a binary file: open using file open modes (rb, rb+,
wb, wb+, ab, ab+), close a binary file, import pickle module, dump() and load()
method, read, write/create, search, append and update operations in a binary file
● CSV file: import csv module, open / close csv file, write into a csv file using
writer(),writerow(),writerows() and read from a csv file using reader()
● Data Structure: Stack, operations on stack (push & pop), implementation of stack
using list.

Unit 2: Computer Networks

● Evolution of networking: introduction to computer networks, evolution of networking


(ARPANET, NSFNET, INTERNET)
● Data communication terminologies: concept of communication, components of
data communication (sender,receiver, message, communication media,
protocols), measuring capacity of communication media (bandwidth, data
transfer rate), IP address, switching techniques (Circuit switching, Packet
switching)
● Transmission media: Wired communication media (Twisted pair cable, Co-axial
cable, Fiber-optic cable), Wireless media (Radio waves, Micro waves, Infrared
waves)
● Network devices (Modem, Ethernet card, RJ45, Repeater, Hub, Switch, Router,
Gateway, WIFI card)
● Network topologies and Network types: types of networks (PAN, LAN, MAN,
WAN), networking topologies (Bus, Star, Tree)
● Network protocol: HTTP, FTP, PPP, SMTP, TCP/IP, POP3, HTTPS, TELNET,
VoIP
● Introduction to web services: WWW, Hyper Text Markup Language (HTML),
Extensible Markup Language (XML), domain names, URL, website, web
browser, web servers, web hosting
Unit 3: Database Management
● Database concepts: introduction to database concepts and its need
● Relational data model: relation, attribute, tuple, domain, degree, cardinality, keys
(candidate key, primary key, alternate key, foreign key)
● Structured Query Language: introduction, Data Definition Language and Data
Manipulation Language, data type (char(n), varchar(n), int, float, date), constraints
(not null, unique, primary key), create database, use database, show databases,
drop database, show tables, create table, describe table, alter table (add and
remove an attribute, add and remove primary key), drop table, insert, delete, select,
operators (mathematical, relational and logical), aliasing, distinct clause, where
clause, in, between, order by, meaning of null, is null, is not null, like, update
command, delete command, aggregate functions (max, min, avg, sum, count),
group by, having clause, joins: cartesian product on two tables, equi-join and
natural join
● Interface of python with an SQL database: connecting SQL with Python, performing
insert, update, delete queries using cursor, display data by using connect(),
cursor(), execute(), commit(), fetchone(), fetchall(), rowcount, creating database
connectivity applications, use of %s format specifier or format() to perform queries

5. Practical

Marks
[Link] Unit Name
(Total=30)

Lab Test:
1 1. Python program (60% logic + 20% 8
documentation + 20% code quality)

2. SQL queries (4 queries based on one


4
or two tables)

Report file:
 Minimum 15 Python programs.
 SQL Queries – Minimum 5 sets using
2 7
one table / two tables.
 Minimum 4 programs based on
Python – SQL connectivity

Project (using concepts learnt in Classes 11


3 8
and 12)

4 Viva voce 3

6. Suggested Practical List:

Python Programming

● Read a text file line by line and display each word separated by a #.
● Read a text file and display the number of vowels/consonants/uppercase/lowercase
characters in the file.
● Remove all the lines that contain the character 'a' in a file and write it to another
file.
● Create a binary file with name and roll number. Search for a given roll number and
display the name, if not found display appropriate message.
● Create a binary file with roll number, name and marks. Input a roll number and
update the marks.
● Write a random number generator that generates random numbers between 1 and
6 (simulates a dice).
● Write a Python program to implement a stack using list.
● Create a CSV file by entering user-id and password, read and search the password
for given userid.
Database Management

● Create a student table and insert data. Implement the following SQL commands on
the student table:
o ALTER table to add new attributes / modify data type / drop attribute
o UPDATE table to modify data
o ORDER By to display data in ascending / descending order
o DELETE to remove tuple(s)
o GROUP BY and find the min, max, sum, count and average
● Similar exercise may be framed for other cases.
● Integrate SQL with Python by importing suitable module.

7. Suggested Reading Material

● NCERT Textbook for COMPUTER SCIENCE (Class XII)


● Support Materials on the CBSE website.

8. Project

The aim of the class project is to create something that is tangible and useful using
Python file handling/ Python-SQL connectivity. This should be done in groups of two to
three students and should be started by students at least 6 months before the
submission deadline. 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 these projects, some additional learning is required;
this should be encouraged. Students should know how to teach themselves.
The students should be sensitized to avoid plagiarism and violations of copyright issues
while working on projects. Teachers should take necessary measures for this.
CBSE Additional Practice Question Paper
Class: XII Session: 2023-24
Computer Science (083)

Time allowed: 3 Hours Maximum Marks: 70

General Instructions:
 Please check this question paper contains 35 questions.
 The paper is divided into 5 Sections- A, B, C, D and E.
 Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
 Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
 Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
 Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
 Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
 All programming questions are to be answered using Python Language only.

Q No. Questions Marks


Section-A (18 Marks)
1 Which of the following is an invalid identifier to be used in Python? 1

a. per%marks
b. _for
c. While
d. true
2 What is the correct way to add an element to the end of a list in 1
Python?

a. [Link](element)
b. [Link](element)
c. [Link](element)
d. [Link](element)
3 What will be the output of 1
print("Welcome To My Blog"[2:6] + "Welcome To My
Blog"[5:9])

a. Lcomme
b. lcomme T
c. lcomme To
d. lcomme
4 Which of the following statements is false? 1

a. A try-except block can have more than one except statement


b. One block of except statement cannot handle multiple exceptions
c. The finally block is always executed
d. When 1 == "1" is executed, no exception is raised
5 Which of the following statement(s) would give an error during the 1
execution of the following code?

R = {'pno':52,'pname':'Virat', 'expert':['Badminton','Tennis'] ,'score':(77,44)}


print(R) #Statement 1
1
R['expert'][0]='Cricket' #Statement 2
R['score'][0]=50 #Statement 3
R['pno']=50 #Statement 4

a. Statement 1
b. Statement 2
c. Statement 3
d. Statement 4
6 Which pickle module method is used to write a Python object to a 1
binary file?

a. save()
b. serialize()
c. store()
d. dump()
7 Given the following dictionaries 1
dict_student = {"rno" : "53", "name" : 'Rajveer Singh'}
dict_marks = {"Accts" : 87, "English" : 65}

Which statement will append the contents of dict_marks in


dict_student?

a. dict_student + dict_marks
b. dict_student.add(dict_marks)
c. dict_student.merge(dict_marks)
d. dict_student.update(dict_marks)
8 Which of the following is not a component of the math module in 1
Python?

a. ceil()
b. mean()
c. fabs()
d. pi
9 What will be the output of the following code? 1
L=["One , Two", "Three", "Four"]
print(len(L)/2*len(L[0]))

a. 6.5
b. 13
c. 13.5
d. 6.0
10 Expand the following terms: 1
(i) PPP
(ii) VoIP
11 Which SQL operator performs pattern matching? 1

a. BETWEEN operator
b. LIKE operator
c. EXISTS operator
d. =

2
12 Which Python function is used for displaying only one result set from 1
SQL table in a database?

a. fetch1()
b. fetchno()
c. fetchall()
d. fetchone()
13 Which of the following file opening mode in Python, generates an 1
error if the file does not exist?

a. a
b. r
c. w
d. w+
14 The correct syntax of seek() is: 1
a. file_object.seek(offset [, reference_point])
b. seek(offset [, reference_point])
c. seek(offset, file_object)
d. seek.file_object(offset)
15 Which of the following statements is false? 1

a. SMTP and POP protocols are used in email communication.


b. URL of a page is not always the same as its domain name.
c. HTTPS is safer than HTTP.
d. Interlinking of collection of webpages is called Internet.
16 Fill in the blank: 1
_________ protocol provides access to services hosted on a remote
computer.

a. FTP
b. PPP
c. Telnet
d. SMTP
Q17 and 18 are ASSERTION AND REASONING based questions.
Mark the correct choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
17 Assertion (A): For changes made to a variable defined within a 1
function to be visible outside the function, it should be declared as
global.
Reasoning (R): Variables defined within a function are local to that
function by default, unless explicitly specified with the global
keyword.
18 Assertion (A): A binary file in python is used to store collection 1
objects like lists and dictionaries that can be later retrieved in their
original form using pickle module.

3
Reasoning (A): Binary files are just like normal text files and can be
read using a text editor like Notepad.
Q No. Questions Marks
Section-B (14 Marks)
19 Write two advantages and two disadvantages of circuit switching. 2
OR
Differentiate between Web server and web browser. Write the names
of any two web browsers.
20 Rewrite the following code in Python after removing all the syntax 2
errors. Underline each correction done in the code.

num1, num2 = 10, 45


While num1 % num2 == 0
num1+= 20
num2+= 30
Else:
print('hello')

21 Write a function dispBook(BOOKS) in Python, that takes a dictionary 2


BOOKS as an argument and displays the names in uppercase of those
books whose name starts with a consonant.

For example, Consider the following dictionary


BOOKS = {1:"Python", 2:"Internet Fundamentals ", 3:"Networking ",
4:"Oracle sets", 5:"Understanding HTML"}

The output should be:


PYTHON
NETWORKING
OR
Write a Python Program containing a function FindWord(STRING,
SEARCH), that accepts two arguments : STRING and SEARCH, and
prints the count of occurrence of SEARCH in STRING. Write
appropriate statements to call the function.

For example, if STRING = "Learning history helps to know about


history with interest in history" and SEARCH = 'history', the function
should display
The word history occurs 3 times.
22 What will be the output of the following code? 2

L = [5,10,15,1]
G = 4
def Change(X):
global G
N=len(X)
for i in range(N):
X[i] += G

Change(L)

for i in L:
print(i,end='$')

4
23 Write a suitable Python statement for each of the following tasks 2
using built-in functions/methods only:
i To delete an element Mumbai:50 from Dictionary D.
ii To display words in a string S in the form of a list
OR
Write a Python Program to display alternate characters of a string
my_str.
For example, if my_str = "Computer Science"
The output should be Cmue cec
24 Differentiate between % (percentage) and _(underscore) characters 2
used with the LIKE operator in SQL with appropriate examples.
OR
Differentiate between DROP and DELETE commands in SQL with
appropriate examples.
25 Consider the following two commands with reference to a table, 2
named Employee having a column named Department:
(a) Select count(Department) from Employee;
(b) Select count(*) from Employee;

If these two commands are producing different results,


(i) What may be the possible reason?
(ii) Which command (a) or (b) might be giving a higher value?
Q No Questions Marks
Section-C (15 Marks)

26 (a) Consider the table, BOOK and MEMBER given below: 3

TABLE : BOOK
CODE BNAME TYPE
F101 The priest Fiction
L102 Easy Python Programming
C101 Juman Ji Thriller
F102 Untold Story Fiction
C102 War Stories Comic

Table: MEMBER
MNO MNAME CODE ISSUEDATE
M101 SNEH SINHA L102 2022-10-13
M103 SARTHAK F102 2021-02-23
M102 SARA KHAN C101 2022-06-12

What will be the output of the following statement?


SELECT * FROM BOOK NATURAL JOIN MEMBER;

(b) Write the output of the queries (i) to (iv) based on the table
Table: Employee
EID Name DOB DOJ Salary Project
E01 Ranjan 1990-07-12 2015-01-21 150000 P01
E02 Akhtar 1992-06-21 2015-02-01 125000 P04
E03 Muneera 1996-11-15 2018-08-19 135000 P01
E04 Alex 1991-10-25 2018-10-19 75000 P02
E05 Satyansh 1993-12-16 2018-10-19 85000 P04

5
i SELECT NAME, PROJECT FROM EMPLOYEE ORDER BY NAME DESC;
ii SELECT NAME, SALARY FROM EMPLOYEE WHERE NAME LIKE 'A%';
iii SELECT NAME, DOJ FROM EMPLOYEE WHERE SALARY BETWEEN
100000 AND 200000;
iv SELECT * FROM EMPLOYEE WHERE PROJECT = 'P01';
27 (a) Consider the following tables – FACULTY and COURSES : 3
Table: FACULTY
FID FNAME LNAME JOINDATE SALARY
F01 Anishma Garg 2000-12-14 32000
F03 Bhumi Goel 2001-08-10 15000
F04 Neha Verma 2000-05-17 27000
F05 Meenu Sharma 2006-07-11 30000

Table: COURSES
C_ID FID CNAME FEES
C11 F01 Grid Computing 40000
C12 F04 Python 17000
C13 F03 C++ 8000
C14 F04 Computer Network 15000
C15 F01 HTML 12000
C16 F05 Data Science NULL

What will be the output of the following statement?


i SELECT FID, MIN(FEES), MAX(FEES) FROM COURSES GROUP BY
FID;
ii SELECT AVG(SALARY) FROM FACULTY WHERE FNAME LIKE '%a';
iii SELECT FNAME, CNAME FROM FACULTY F, COURSES C WHERE
[Link]=[Link] AND [Link]='F04';
iv SELECT FNAME, CNAME , FEES FROM FACULTY F , COURSES C
WHERE [Link] = [Link] AND FEE>15000;

(b) Write the name of the command to display the structure of a


table in a database.
28 Write a function COUNT() in Python to read from a text file 3
'[Link]' and display the count of the letter 'e' in each
line
Example: If the file content is as follows:
Gratitude is a humble heart's radiant glow,
A timeless gift that nurtures and bestows.
It's the appreciation for the love we're shown,
In moments big and small, it's truly known.

The COUNT() function should display the output as:


Line 1 : 3
Line 2 : 4
Line 3 : 6
Line 4 : 1
OR
Write a function Start_with_I() in Python, which should read a
text file '[Link]' and then display lines starting with 'I'.
Example: If the file content is as follows:
Gratitude is a humble heart's radiant glow,
A timeless gift that nurtures and bestows.
It's the appreciation for the love we're shown,
In moments big and small, it's truly known.

6
Then the output should be
It's the appreciation for the love we're shown,
In moments big and small, it's truly known.
29 Navdeep creates a table RESULT with a set of records to maintain the 3
marks secured by students in Sem1, Sem2, Sem3, and their divisions.
After the creation of the table, he entered data of 7 students in the
table.
ADNO ROLLNO SNAME SEM1 SEM2 DIVISION
123 101 KARAN 366 410 I
245 102 NAMAN 300 350 I
128 103 ISHA 400 410 I
129 104 RENU 350 357 I
234 105 ARPIT 100 75 IV
187 106 SABINA 100 205 II
181 107 NEELAM 470 450 I

Based on the data given above answer the following questions:


i Identify the columns which can be considered as candidate
keys?
ii If 2 more columns are added and 3 rows are deleted from the
table result, what will be the new degree and cardinality of the
above table?
iii Write a statement to increase the SEM2 marks by 3% for the
students securing marks between 70 to 100.
30 Given a Dictionary Stu_dict containing marks of students for three 3
test-series in the form Stu_ID:(TS1, TS2, TS3) as key-value pairs.
Write a Python program with the following user-defined functions to
perform the specified operations on a stack named Stu_Stk

(i) Push_elements(Stu_Stk, Stu_dict) : It allows pushing


IDs of those students, from the dictionary Stu_dict into the stack
Stu_Stk, who have scored more than or equal to 80 marks in the TS3
Test.
(ii) Pop_elements(Stu_Stk): It removes all elements present
inside the stack in LIFO order and prints them. Also, the function
displays 'Stack Empty' when there are no elements in the stack.
Call both functions to execute queries.

For example:
If the dictionary Stu_dict contains the following data:
Stu_dict ={5:(87,68,89), 10:(57,54,61), 12:(71,67,90),
14:(66,81,80), 18:(80,48,91)}

After executing Push_elements(), Stk_ID should contain


[5,12,14,18]

After executing Pop_elements(), The output should be:


18
14
12
5
Stack Empty

7
Q No. Questions Marks
Section-D (8 Marks)
31 Create a function maxsalary() in Python to read all the records 4
from an already existing file [Link] which stores the records
of various employees working in a department. Data is stored under
various fields as shown below:
E_code E_name Scale Salary
A01 Bijesh Mehra S4 65400
B02 Vikram Goel S3 60000
C09 Suraj Mehta S2 45300
…… …… …… ……
Function should display the row where the salary is maximum.
Note: Assume that all employees have distinct salary.
32 Consider a binary file '[Link]' that stores information 4
about products using tuple with the structure (ProductID,
ProductName, Quantity, Price). Write a Python function
expensiveProducts() to read the contents of
'[Link]' and display details of products with a price
higher than Rs. 1000. Additionally, calculate and display the total
count of such expensive products.

For example: If the file stores the following data in binary format
(1, 'ABC', 100, 5000)
(2, 'DEF', 250, 1000)
(3, 'GHI', 300, 2000)
then the function should display
Product ID: 1
Product ID: 3
Total expensive products: 2
Q No. Questions Marks
Section-E (15 Marks)
33 Fun Media Services Ltd is an event planning organization. It is 5
planning to set up its India campus in Mumbai with its head office in
Delhi. The Mumbai campus will have four blocks/buildings -
ADMIN, DECORATORS, FOOD, and MEDIA.
You as a network expert need to suggest the best network-related
solutions for them to resolve the issues/problems mentioned in points
(i) to (v), keeping in mind the distances between various
blocks/buildings and other given parameters.

8
Shortest distance between various buildings:
FROM – TO DISTANCE
ADMIN TO DECORATORS 90 meters
ADMIN TO MEDIA 75 meters
ADMIN TO FOOD 50 meters
DECORATORS TO FOOD 65 meters
DECORATORS TO MEDIA 50 meters
FOOD TO MEDIA 45 meters
DELHI Head Office to MUMBAI 1475 KM
Campus

The number of computers at various buildings is as follows:


BUILDING NUMBER OF COMPUTERS
ADMIN 110
DECORATORS 75
MEDIA 12
FOOD 20

i. Suggest the most appropriate location of the server inside the


MUMBAI campus (out of the 4 buildings). Justify your answer.
ii. Draw the cable layout to efficiently connect various buildings
within the MUMBAI campus.
iii. Which hardware device will you suggest to connect all the
computers within each building?
iv. Which of the following will you suggest to establish online
face-to-face communication between the people in the Admin
Office of the MUMBAI campus and the DELHI Head Office?
a. Cable TV
b. Email
c. Video Conferencing
d. Text Chat
v. What type of network (out of PAN, LAN, MAN, WAN) will
be set up in each of the following cases?
a. The Mumbai campus gets connected with the Head Quarter
in Delhi
b. The computers connected in the MUMBAI campus
34 i. Mention any two differences between seek() and tell(). 2+3=5
ii. Consider a file [Link] containing multiple records. The
structure of each record is as shown below:
[Fno, FName, Fare, Source, Destination]
Write a function COPY_REC() in Python that copies all those
records from [Link] where the source is DELHI and the
destination is MUMBAI, into a new file [Link]
OR
i. Mention any two differences between binary files and csv files?
ii. Consider a Binary file [Link] containing a dictionary
having multiple elements. Each element is in the form
BNO:[BNAME,BTYPE,PRICE] as key:value pair
where
BNO – Book Number
BNAME – Book Name
BTYPE - Book Type
PRICE – Book price

9
Write a user-defined function, findBook(price), that accepts
price as parameter and displays all those records from the
binary file [Link] which has a book price more than or equal
to the price value passed as a parameter.
35 i. Define the term constraint with respect to RDBMS. Give a 5
suitable example.
ii. Sameera maintains a database named STORE which contains a
table named ITEM with the structure given below:
• Ino(Item number )- integer
• Iname(Item Name) – string
• Price (Item Price) – float
• Discount (Discount) – float
Note the following to establish connectivity between Python
and MySQL:
• Username - root
• Password - tiger
• Host - localhost
Help her to remove the record from the table ITEM for a particular
value of item name input by the user.
import [Link] as mysql
con1= [Link](host='localhost', user='root', password=
'__', database='STORE') #Statement-1
mycursor = ________ #Statement-2
item_name = input("Enter the Item name to remove the record : ")
query = ______________ #Statement-3
[Link](query)
con1.____ #Statement-4
print('Data Deleted successfully')
[Link]()

With reference to the above code, answer the following questions


a) Complete statement 1 to establish the connection with the
database.
b) Write statement 2 to create the cursor object.
c) Complete statement 3 to remove the record from the table
ITEM based on the item name entered by the user
d) Complete statement 4 to save the changes in the table.
OR
i. Write one difference between the alternate key and the
candidate key.
ii. A table named ITEM is created in a database STORE. The table
contains multiple columns whose details are as shown below:
 Ino(Item number )- integer
 Iname(Item Name) – string
 Price (Item Price) – float
 Discount (Discount) – float

Note the following to establish connectivity between Python


and MySQL:
 Username - root
 Password - tiger
 Host - localhost
However, the table is to be interfaced with Python to perform
certain tasks. The incomplete code is given below:
10
______ #Line 1
con1= [Link](host='localhost', user = 'root', password =
'tiger', database='STORE')
mycursor = con1.____ #Line 2
query = 'SELECT * FROM ITEM where Price > {}'.format(___) #Line3
[Link](query)
data = mycursor.___ #Line 4
for rec in data:
print(rec)
[Link]()
i. Complete line 1 to import the appropriate module.
ii. Complete Line 2 to create the cursor object
iii. Complete the query given in Line 3 to display details of all such
items from the table ITEMS whose price is more than 5000.
iv. Complete Line 4 to extract all the records.

11
Class: XII
Subject: COMPUTER SCIENCE
Q. No. 1 Rohit, a student of class 12th, is learning CSV File Module in Python. During
examination, he has been assigned an incomplete python code (shown below)
to create a CSV File '[Link]' (content shown below). Help him in
completing the code which creates the desired CSV File.

CSV File
1,AKSHAY,XII,A
2,ABHISHEK,XII,A
3,ARVIND,XII,A
4,RAVI,XII,A
5,ASHISH,XII,A

Incomplete Code
import_____ #Statement-1
fh = open(_____, _____, newline='') #Statement-2
stuwriter = csv._____ #Statement-3
data = []
header = ['ROLL_NO', 'NAME', 'CLASS', 'SECTION']
[Link](header)
for i in range(5):
roll_no = int(input("Enter Roll Number : "))
name = input("Enter Name : ")
Class = input("Enter Class : ")
section = input("Enter Section : ")
rec = [_____] #Statement-4
[Link](rec)
stuwriter. _____ (data) #Statement-5
[Link]()
i. Identify the suitable code for blank space in line marked as Statement-1.
a) csv file
b) CSV
c) csv
d) Csv

Correct Answer : c) csv


ii. Identify the missing code for blank space in line marked as Statement-2?
a) "[Link]","w"
b) "[Link]","w"
c) "[Link]","r"
d) "[Link]","r"

Correct Answer : b) "[Link]","w"


iii. Choose the function name (with argument) that should be used in the blank
space of line marked as Statement-3
a) reader(fh)
b) reader(MyFile)
c) writer(fh)
d) writer(MyFile)
Correct Answer : c) writer(fh)
iv. Identify the suitable code for blank space in line marked as Statement-4.
a) 'ROLL_NO', 'NAME', 'CLASS', 'SECTION'
b) ROLL_NO, NAME, CLASS, SECTION
c) 'roll_no','name','Class','section'
d) roll_no,name,Class,section c) [Link]()

Correct Answer : d) roll_no,name,Class,section


v. Choose the function name that should be used in the blank space of line marked
as Statement-5 to create the desired CSV File?
a) dump()
b) load()
c) writerows()
d) writerow()

Correct Answer : c) writerows()

Q. No. 2 Amritya Seth is a programmer, who has recently been given a task to write a
python code to perform the following binary file operations with the help of
two user defined functions/modules:

a. AddStudents() to create a binary file called [Link]


containing student information – roll number, name and marks (out
of 100) of each student.
b. GetStudents() to display the name and percentage of those students
who have a percentage greater than 75. In case there is no student
having percentage > 75 the function displays an appropriate
message. The function should also display the average percent.

He has succeeded in writing partial code and has missed out certain
statements, so he has left certain queries in comment lines. You as an expert
of Python have to provide the missing statements and other related queries
based on the following code of Amritya.

Answer any four questions (out of five) from the below mentioned questions.

import pickle
def AddStudents():
____________ #1 statement to open the binary file to
write data
while True:
Rno = int(input("Rno :"))
Name = input("Name : ")
Percent = float(input("Percent :"))
L = [Rno, Name, Percent]
____________ #2 statement to write the list L
into the file
Choice = input("enter more (y/n): ")
if Choice in "nN":
break
[Link]()
def GetStudents():
Total=0
Countrec=0
Countabove75=0
with open("[Link]","rb") as F:
while True:
try:
____________ #3 statement to read
from the file
Countrec+=1
Total+=R[2]
if R[2] > 75:
print(R[1], " has percent =
",R[2])
Countabove75+=1
except:
break
if Countabove75==0:
print("There is no student who has
percentage more than 75")
average=Total/Countrec
print("average percent of class = ",average)

AddStudents()
GetStudents()
i. Which of the following commands is used to open the file “[Link]”
for writing only in binary format? (marked as #1 in the Python code)
a. F= open("[Link]",'wb')
b. F= open("[Link]",'w')
c. F= open("[Link]",'wb+')
d. F= open("[Link]",'w+')

Correct Answer : a. F= open("[Link]",'wb')


ii. Which of the following commands is used to write the list L into the binary file,
[Link]? (marked as #2 in the Python code)
a. [Link](L,f)
b. [Link](f, L)
c. [Link](L,F)
d. f=[Link](L)

Correct Answer : c. [Link](L,F)


iii. Which of the following commands is used to read each record from the binary
file [Link]? (marked as #3 in the Python code)
a. R = [Link](F)
b. [Link](r,f)
c. r= [Link](f)
d. [Link](r,f)

Correct Answer : a. R = [Link](F)


iv. Which of the following statement(s) are correct regarding the file access
modes?
a. ‘r+’ opens a file for both reading and writing. File object points to its
beginning.
b. ‘w+’ opens a file for both writing and reading. Adds at the end of the
existing file if it exists and creates a new one if it does not exist.
c. ‘wb’ opens a file for reading and writing in binary format. Overwrites
the file if it exists and creates a new one if it does not exist.
d. ‘a’ opens a file for appending. The file pointer is at the start of the file
if the file exists.

Correct Answer : a
v. Which of the following statements correctly explain the function of seek()
method?
a. tells the current position within the file.
b. determines if you can move the file position or not.
c. indicates that the next read or write occurs from that position in a file.
d. moves the current file position to a given specified position

Correct Answer : d

Q. No. 3 Krrishnav is looking for his dream job but has some restrictions. He loves Delhi
and would take a job there if he is paid over Rs.40,000 a month. He hates
Chennai and demands at least Rs. 1,00,000 to work there. In any another
location he is willing to work for Rs. 60,000 a month. The following code
shows his basic strategy for evaluating a job offer.

Code:

pay= _________
location= _________
if location == "Mumbai":
print ("I’ll take it!") #Statement 1
elif location == "Chennai":
if pay < 100000:
print ("No way") #Statement 2
else:
print("I am willing!") #Statement 3
elif location == "Delhi" and pay > 40000:
print("I am happy to join") #Statement 4
elif pay > 60000:
print("I accept the offer") #Statement 5
else:
print("No thanks, I can find something
better")#Statement 6

On the basis of the above code, choose the right statement which will be
executed when different inputs for pay and location are given.
i. Input: location = "Chennai”, pay = 50000
a. Statement 1
b. Statement 2
c. Statement 3
d. Statement 4
Correct Answer : ii. Statement 2
ii. Input: location = "Surat" ,pay = 50000
a. Statement 2
b. Statement 4
c. Statement 5
d. Statement 6

Correct Answer: d. Statement 6


iii. Input- location = "Any Other City", pay = 1

a Statement 1
b. Statement 2
c. Statement 4
d. Statement 6

Correct Answer: d. Statement 6


iv. Input location = "Delhi", pay = 500000
a. Statement 6
b. Statement 5
c. Statement 4
d. Statement 3

Correct Answer: c. Statement 4


v. v. Input- location = "Lucknow", pay = 65000
i. Statement 2
ii. Statement 3
iii. Statement 4
iv. Statement 5

Correct Answer: d. Statement 5

Q. No. 4 Consider the following code and answer the questions that follow:
Book={1:'Thriller', 2:'Mystery', 3:'Crime', 4:'Children
Stories'}
Library ={'5':'Madras Diaries','6':'Malgudi Days'}
i. Ramesh needs to change the title in the dictionary book from ‘Crime’ to ‘Crime
Thriller’. He has written the following command:
Book[‘Crime’]=’Crime Thriller’
But he is not getting the answer. Help him choose the correct command:
a. Book[2]=’Crime Thriller’
b. Book[3]=’Crime Thriller’
c. Book[2]=(’Crime Thriller’)
d. Book[3] =(‘Crime Thriller’)

Correct Answer: b
ii. The command to merge the dictionary Book with Library the command would
be:
a. d=Book+Library
b. print(Book+Library)
c. [Link](Library)
d. [Link](Book)
Correct Answer: d
iii. What will be the output of the following line of code:
print(list(Library))
a. [‘5’,’Madras Diaries’,’6’,’Malgudi Days’]
b. (‘5’,’Madras Diaries’,’6’,’Malgudi Days’)
c. [’Madras Diaries’,’Malgudi Days’]
d. [‘5’,’6’]

Correct Answer: d
iv. In order to check whether the key 2 is present in the dictionary Book, Ramesh
uses the following command:
2 in Book
He gets the answer ‘True’. Now to check whether the name ‘Madras Diaries’
exists in the dictionary Library, he uses the following command:
‘Madras Diaries’ in Library
But he gets the answer as ‘False’. Select the correct reason for this:
a. We cannot use the in function with values. It can be used with keys only.
b. We must use the function [Link]() along with the in operator
c. We can use the [Link]() function instead of the in operator
d. Both b and c above are correct.

Correct Answer: b
v. With reference to the above declared dictionaries, predict the output of the
following code fragments
Code 1 Code 2
Library=Book Library=[Link]()
[Link](2) [Link](2)
print(Library) print(Library)
print(Book) print(Book)

a) Code 1 Code 2
{1: 'Thriller', 2: {1: 'Thriller', 3:
'Mystery', 3: 'Crime', 'Crime', 4: 'Children
4: 'Children Stories'} Stories'}
{1: 'Thriller', 2: {1: 'Thriller', 3:
'Mystery', 3: 'Crime', 'Crime', 4: 'Children
4: 'Children Stories'} Stories'}

b) Code 1 Code 2
{1: 'Thriller', 3:
'Crime', 4: 'Children
{2:’Mystery’} Stories'}
{1: 'Thriller', 2: {1: 'Thriller', 3:
'Mystery', 3: 'Crime', 'Crime', 4: 'Children
4: 'Children Stories'} Stories'}

c) Code 1 Code 2
{1: 'Thriller', 3: {1: 'Thriller', 3:
'Crime', 4: 'Children 'Crime', 4: 'Children
Stories'} Stories'}
{1: 'Thriller', 3: {1: 'Thriller', 2:
'Crime', 4: 'Children 'Mystery', 3: 'Crime', 4:
Stories'} 'Children Stories'}

d) Code 1 Code 2
{1: 'Thriller', 3: {1: 'Thriller', 3:
'Crime', 4: 'Children 'Crime', 4: 'Children
Stories'} Stories'}
{1: 'Thriller', 2: {1: 'Thriller', 3:
'Mystery', 3: 'Crime', 'Crime', 4: 'Children
4: 'Children Stories'} Stories'}

Correct Answer: c

Q. No. 5 In a Database, there are two tables with the instances given below:

Table: STUDENTS
ADMNO NAME CLASS SEC RNO ADDRESS PHONE
1211 MEENA 12A D 4 A-26 3245678
1212 VANI 10A D 1 B-25 5456789
1213 MEENA 12B A 1 NULL NULL
1214 KARISH 10B B 3 AB-234 4567890

Table: SPORTS
ADMNO GAME COACHNAME GRADE
1215 CRICKET MR. RAVI A
1213 VOLLEYBALL MR. AMANDEEP B
1211 VOLLEYBALL MR. GOVARDHAN A
1212 BASKET BALL MR TEWARI B

i. Choose the command to display name and game of those students whose
address is available in students’ table.

a. SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE


[Link]=[Link] AND ADDRESS IS NOT
NULL;
b. SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE
[Link]=[Link] AND ADDRESS IS
NULL;
c. SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE
[Link]=[Link], ADDRESS IS NULL;
d. SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE
[Link]=[Link] NOT ADDRESS IS
NULL;
Correct Answer:
a. SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE
[Link]=[Link] AND ADDRESS IS NOT
NULL;
ii. Identify the statement to delete a column phone from the table students.

a. ALTER TABLE STUDENTS DROP PHONE;


b. DROP PHONE;
c. UPDATE DROP PHONE;
d. DELETE FROM STUDENTS WHERE DROP PHONE;

Correct Answer:
a. ALTER TABLE STUDENTS DROP PHONE;
iii. Choose the command to display Name of the students who are studying in class
12 and their corresponding Coach names

a. SELECT NAME, COACHNAME FROM STUDENTS, SPORTS


WHERE CLASS LIKE “12%” AND [Link]
=[Link];
b. SELECT NAME, COACHNAME FROM STUDENTS, SPORTS
WHERE CLASS LIKE “12%” AND [Link]=
[Link];
c. SELECT NAME, COACHNAME FROM STUDENTS, SPORTS
WHERE CLASS LIKE “12%” AND [Link]
=[Link];
d. SELECT NAME, COACHNAME FROM STUDENTS, SPORTS
WHERE CLASS LIKE= “12%” AND [Link]
=[Link];

Correct Answer:
a. SELECT NAME, COACHNAME FROM STUDENTS,SPORTS WHERE
CLASS LIKE “12%” AND [Link]=[Link] ;
iv. which two select queries will give the same output

A. SELECT NAME, GRADE FROM STUDENTS,SPORTS WHERE


ADDRESS IS NULL AND [Link] =[Link] ;
B. SELECT NAME, GRADE FROM STUDENTS,SPORTS WHERE
ADDRESS IS NOT NULL AND [Link]
=[Link] ;
C SELECT NAME, GRADE FROM STUDENTS,SPORTS WHERE
ADDRESS IS NULL OR [Link]=[Link] ;
D. SELECT [Link], [Link] FROM STUDENTS ST,SPORTS SP
WHERE ADDRESS IS NULL AND [Link]=[Link] ;
a. A AND B
b. B AND C
c. A AND D
d. C AND D

Correct Answer: c. A AND D


v. Choose the command to count the number of students who play volleyball

a. SELECT COUNT(*) FROM STUDENTS,SPORTS WHERE


GAME=”VOLLEYBALL” AND [Link]=[Link]
;
b. SELECT COUNT(GAME) FROM STUDENTS,SPORTS WHERE
GAME=”VOLLEYBALL” AND [Link]=[Link]
;
c. SELECT COUNT(*) FROM STUDENTS,SPORTS WHERE
GAME=”VOLLEYBALL” ;
d. SELECT COUNT(*) FROM STUDENTS,SPORTS WHERE
SPORTS=”VOLLEYBALL” AND
[Link]=[Link]

Correct Answer :
a. SELECT COUNT(*) FROM STUDENTS,SPORTS WHERE
GAME=”VOLLEYBALL” AND [Link]=[Link]
;

Q. No. 6 A company ABC Enterprises has four blocks of buildings as shown:

B1 B4

B2 B3

Center to center distance between various blocks


B3 TO B1 50 M
B1 TO B2 60 M
B2 TO B4 25 M
B4 TO B3 170 M
B3 TO B2 125 M
B1 TO B4 90 M

Number of computers in each block :


B1 150 M
B2 15 M
B3 15 M
B4 25 M
Computers in each block are networked but blocks are not networked. The
company has now decided to connect the blocks also.

i. Suggest the most appropriate topology for the connections between the blocks.
a. Ring topology
b. Star topology
c. Mesh topology
d. Bus topology
Correct Answer: b. Star topology
ii. The company wants internet accessibility in all the blocks. The suitable and
cost-effective technology for that would be:
a. Satellite
b. Lease line
c. Telephone line
d. Broadband

Correct Answer: d. Broadband

iii. Which one of the following devices will you suggest for connecting all the
computers with in each of their blocks?
a. Switch/Hub
b. Modem
c. Telephone
d. Repeater

Correct Answer: a. Switch/Hub


iv. The company is planning to link its head office situated in New Delhi with the
offices in hilly areas. Suggest a way to connect it economically:
a. Micro waves
b. Coaxial cable
c. Fibre optic
d. Radio waves

Correct Answer: d. Radio waves


v. Suggest the most appropriate location of the server, to get the best connectivity
for maximum number of computers.
a. BLOCK B2
b. BLOCK B1
c. BLOCK B4
d. BLOCK B3

Correct Answer: b. BLOCK B1

Q. No. 7 Millions of computer science students have taken a course on algorithms and
data structures, typically the second course after the initial one introducing
programming. One of the basic data structures in such a course is the stack. The
stack has a special place in the emergence of computing as a science, as argued
by Michael Mahoney, the pioneer of the history of the theory of computing.
The Stack can be used in many computer applications, few are given below:
a) In recursive function
b) When function is called.
c) Expression conversion such as – Infix to Postfix, Infix to Prefix, Postfix
to Infix, Prefix to Infix.
In Stack, insertion operation is known as Push whereas deletion operation is
known as Pop.

Code – 1
def push(Country,N):
Country._________(len(Country),N)) #Statement 1

#Function Calling
Country=[]
C=['Indian', 'USA', 'UK', 'Canada', 'Sri Lanka']
for i in range(0,len(C),________): #Statement 2
push(Country,C[i])
print(Country)

Required Output:
['Indian', 'UK', 'Sri Lanka']

Code - 2
def pop(Country):
if ______________: #Statement 3
return "Under flow"
else:
return Country.________() #Statement 4

#Function Calling
for i in range(len(Country)+1):
print(_______________) #Statement 5

Required Output:
Sri Lanka
UK
India
Under flow

Fill the above statement based on given questions:


i. Identify the suitable code for the blank of statement 1.
a. .append()
b. .insert()
c. .extend()
d. .append(len(Country),N)

Correct Answer : b. .insert()


ii. Fill the statement 2, to insert the alternate element from Country list.
a. 3
b. 0
c. -1
d. 2

Correct Answer : d. 2
iii. Fill the statement 3, to check the stack is empty.
a. Country=[]
b. [Link]()
c. len(country)==0
d. No of the above
Correct Answer : c. len(country)==0
iv. Fill the statement 4, to delete an element from the stack.
a. pop(1)
b. pop()
c. del country[1]
d. [Link](1)

Correct Answer: b. pop()

v. Fill the statement 5, to call the pop function.


a. pop(C)
b. pop(Country)
c. call pop(Country)
d. def pop(Country)

Correct Answer: b. pop(Country)

Q. No. 8 Arun, during Practical Examination of Computer Science, has been assigned
an incomplete search() function to search in a pickled file [Link]. The File
[Link] is created by his Teacher and the following information is known
about the file.
• File contains details of students in [roll_no,name,marks] format.
• File contains details of 10 students (i.e. from roll_no 1 to 10) and
separate list of each student is written in the binary file using dump().
Arun has been assigned the task to complete the code and print details of roll
number 1.

def search():
f = open("[Link]",____)
#Statement-1
____: #Statement-2
while True:
rec = pickle.____
#Statement-3
if(____): #Statement-4
print(rec)
except:
pass
____ #Statement-5

i. In which mode Arun should open the file in Statement-1?


a) r
b) r+
c) rb
d) wb

Correct Answer: c) rb
ii. Identify the suitable code to be used at blank space in line marked as Statement-
2
a) if(rec[0]==1)
b) for i in range(10)
c) try
d) pass

Correct Answer: c) try


iii. Identify the function (with argument), to be used at blank space in line marked
as Statement-3.
a) load()
b) load([Link])
c) load(f)
d) load(fin)

Correct Answer: c) load(f)


iv. What will be the suitable code for blank space in line marked as Statement-4.
a) rec[0]==2
b) rec[1]==2
c) rec[2]==2
d) rec[0]==1

Correct Answer: d) rec[0]==1


v. Which statement Arun should use at blank space in line marked as Statement-
4 to close the file.
a) [Link]()
b) close(file)
c) [Link]()
d) close()

Correct Answer: c) [Link]()

Q. No. 9 Radha Shah is a programmer, who has recently been given a task to write a
python code to perform the following CSV file operations with the help of two
user defined functions/modules:

a. CSVOpen() : to create a CSV file called [Link] in append mode


containing information of books – Title, Author and Price.
b. CSVRead() : to display the records from the CSV file called
[Link] where the field title starts with 'R'.
She has succeeded in writing partial code and has missed out certain statements,
so she has left certain queries in comment lines.

import csv
def CSVOpen():
with open('[Link]','______',newline='') as csvf:
#Statement-1
cw=______ #Statement-2
______ #Statement-3
[Link](['Rapunzel','Jack',300])
[Link](['Barbie','Doll',900])
[Link](['Johnny','Jane',280])

def CSVRead():
try:
with open('[Link]','r') as csvf:
cr=______ #Statement-4
for r in cr:
if ______: #Statement-5
print(r)
except:
print('File Not Found')

CSVOpen()
CSVRead()

You as an expert of Python have to provide the missing statements and other
related queries based on the following code of Radha.
Answer any four questions (out of five) from the below mentioned questions.
i. Choose the appropriate mode in which the file is to be opened in append mode
(Statement 1)
a. w+
b. ab
c. r+
d. a

Correct Answer: d. a
ii. Which statement will be used to create a csv writer object in Statement 2.
a. [Link](csvf)
b. [Link](csvf)
c. [Link]()
d. [Link](csvf)

Correct Answer: b. [Link](csvf)


iii. Choose the correct option for Statement 3 to write the names of the column
headings in the CSV file, [Link].
a. [Link]('Title','Author','Price')
b. [Link](['Title','Author','Price'])
c. [Link]('Title','Author','Price')
d. [Link](['Title','Author','Price'])

Correct Answer: b. [Link](['Title','Author','Price'])


iv. Which statement will be used to read a csv file in Statement 4.
a. [Link](csvf)
b. [Link](csvf)
c. [Link]()
d. [Link](cs)

Correct Answer: b. [Link](csvf)


v. Fill in the appropriate statement to check the field Title starting with ‘R’ for
Statement 5 in the above program.
a. r[0][0]=='R'
b. r[1][0]=='R'
c. r[0][1]=='R'
d. d) r[1][1]=='R'

Correct Answer: a. r[0][0]=='R'

Q. No. 10 Ankita is writing a program to perform some operations in Queue. She has
created three Insert_in_Queue(Student), Delete_from_Queue(Student) and
Print_Queue(Student) methods/functions in Python to add a new Student name,
delete a Student name and print list of student from a queue, considering them
to act as insert, delete and print operations of the Queue data structure. She is
not getting the desired result. Help her to get the desired result from the given
python code.
def Insert_in_Queue(queue):
a=input("enter student name: ")
queue.____________ # Statement-1

def Delete_from_Queue (queue):


if (____________): # Statement-2
print("Queue empty")
else:
print("Deleted element is: ",queue[0])
del queue[___] #Statement-3

def Print_Queue(queue):
if not ________: #Statement-4
print(queue[__:___ ]) # Statement-5
i. What Ankita should write to complete the Statement-1 to store the student
name?
a. [Link](a)
b. queue=append(a)
c. [Link]=a
d. append(a).queue

Correct Answer: a [Link](a)


ii. Fill in the blank in Statement-2 to check whether the queue is empty or not?
a. isEmpty(Queue)
b. isEmpty(q)
c. [Link]
d. [Link]

Correct Answer: a isEmpty(Queue)


iii. iii. Fill in the blank in Statement-3 with index number.
a. delete(0)
b. del queue[0]
c. [Link](0)
d. [Link][0]

Correct Answer: b) del queue[0]


iv. Select the correct option to complete the statement at statement-4.
a. isEmpty( )
b. Empty( )
c. len( ) = 0
d. not Empty

Correct Answer : a isEmpty( )


v. Specify the range to print all queue elements in statement-5?
a. print(queue=[0:len=(queue)])
b. print(queue[0:len(queue)])
c. print(queue[[0:len]])
d. print(queue[0=len(queue)])

Correct Answer : b. print(queue[0:len(queue)])

Q. No. 11 Priyank is a software developer with a reputed firm. He has been given the task
to computerise the operations for which he is developing a form which will
accept customer data as follows:
i. The DATA TO BE ENTERED IS :
a. Name
b. Age
c. Items bought( all the items that the customer bought)
d. Bill amount

Correct Answer :
i. Choose the most appropriate data type to store the above information
in the given sequence.
a. string, tuple, float, integer
b. string, integer, dictionary, float
c. string, integer, integer, float
d. string, integer, list, float

Correct Answer :
ii. Now the data of each customer needs to be organised such that the
customer can be identified by name followed by the age, item list and bill
amount. Choose the appropriate data type that will help Priyank accomplish
this task.
a. List
b. Dictionary
c. Nested Dictionary
d. Tuple

Correct Answer :
iii. Which of the following is the correct way of storing information of
customers named ‘Paritosh’ and ‘Bhavesh’ with respect to the option chosen
above?
a. [Link]= {‘Paritosh’:24,[‘Printed Paper’, ‘ Penstand’], 3409,
‘Bhavesh’: 45,[‘A4 Rim’,’Printer Cartridge’, ‘Pen Carton’, ‘Gift Wrap’],
8099.99 }
b. customers={‘Paritosh’:[24,[‘Printed Paper’, ‘ Penstand’], 3409],
‘Bhavesh’: [45,[‘A4 Rim’,’Printer Cartridge’, ‘Pen Carton’, ‘Gift Wrap’],
8099.99] }
c. [Link]= [‘Paritosh’:24,‘Printed Paper’, ‘ Penstand’, 3409,
‘Bhavesh’: 45,‘A4 Rim’,’Printer Cartridge’, ‘Pen Carton’, ‘Gift Wrap’,
8099.99 ]
d. customers=(‘Paritosh’:24,[‘Printed Paper’, ‘ Penstand’], 3409,
‘Bhavesh’: 45,[‘A4 Rim’,’Printer Cartridge’, ‘Pen Carton’, ‘Gift Wrap’],
8099.99 )

Correct Answer :
iv. In order to calculate the total bill amount for 15 customers, Priyank
Statement 1. must use a variable of the type float to store the sum.
Statement 2. may use a loop to iterate over the values
a. Both statements are correct.
b. Statement 1 is correct, but statemnt 2 is not.
c. Both statements ar incorrect.
d. Statement 1 is incorrect but statement 2 is correct.

Correct Answer :

Q. No. 12 Your teacher has given you a method/function FilterWords() in python which
read lines from a text file [Link], and display those words, which are
lesser than 4 characters. Your teachers intentionally kept few blanks in between
the code and asked you to fill the blanks so that the code will run to find desired
result. Do the needful with the following python code.

def FilterWords():
c=0
file=open('[Link]', '_____') #Statement-1
line = file._____ #Statement-2
word = _____ #Statement-3
for c in word:
if _____: #Statement-4
print(c)
_________ #Statement-5

FilterWords()
i. Write mode of opening the file in statement-1?
a. a
b. ab
c. w
d. r

Correct Answer: d. r
ii. Fill in the blank in statement-2 to read the data from the file.
a. [Link]()
b. [Link]()
c. [Link]( )
d. readlines( )

Correct Answer: b. [Link]()


iii. Fill in the blank in statement-3 to read data word by word.
a. [Link]()
b. [Link]()
c. [Link]()
d. [Link]()

Correct Answer: c. [Link]()


iv. Fill in the blank in statement-4, which display the word having lesser than 4
characters.
a. len(c) ==4
b. len(c)<4
c. len ( )= =3
d. len ( )==3

Correct Answer: b. len(c)<4


v. Fill in the blank in Statement-5 to close the file.
a. [Link]()
b. [Link]()
c. Close()
d. end()

Correct Answer: a. [Link]()

You might also like