0% found this document useful (0 votes)
20 views10 pages

QP_CS_XII_I PB

The document is a question paper for the First Pre-Board Exam in Computer Science (Python) for Class XII, issued by Kendriya Vidyalaya Sangathan, Raipur Region. It consists of 37 compulsory questions divided into five sections, covering various topics in Python programming, SQL, and computer networking, with a total of 70 marks. The exam duration is 3 hours, and it includes programming tasks, theoretical questions, and assertions based on given statements.

Uploaded by

vipshelpdesk2
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)
20 views10 pages

QP_CS_XII_I PB

The document is a question paper for the First Pre-Board Exam in Computer Science (Python) for Class XII, issued by Kendriya Vidyalaya Sangathan, Raipur Region. It consists of 37 compulsory questions divided into five sections, covering various topics in Python programming, SQL, and computer networking, with a total of 70 marks. The exam duration is 3 hours, and it includes programming tasks, theoretical questions, and assertions based on given statements.

Uploaded by

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

KENDRIYA VIDYALAYA SANGATHAN, RAIPUR REGION

FIRST PRE-BOARD EXAM (2024-25)


SUB: COMPUTER SCIENCE (Python) (083)
CLASS: XII
Max Marks: 70 TIME: 03 HOURS
General Instructions
This question paper contains 37 questions.
All questions are compulsory. However, internal choices have been provided in
some questions. Attempt only one of the choices in such questions
The paper is divided into 5 Sections- A, B, C, D and E.
Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
All programming questions are to be answered using Python Language only.
In case of MCQ, text of the correct answer should also be written.

PART A
01 Which exception is raised when attempting to access a non-existent file? 1
(a) FileNotFoundError
(b) FileNotAccessibleError
(c) NonExistentFileError
(d) InvalidFileAccessError
02 Find the output of the following code. 1
Name=” PythoN3@1”
R=” “
for x in range(len(Name)):
if Name[x]. isupper():
R=R+Name[x]. lower ()
elif Name[x]. islower():
R=R+Name[x]. upper ()
elif Name[x]. isdigit:
R=R+Name[N-1]
else:
R=R+”#”
Print(R)
(a) pYTHOn##@ (b) pYTHOnN#@
(c) pYTHOn#@ (d) pYTHOnN@#
03 Which of the following is the correct output for the execution of the following 1
Python statement?
print (5 + 3 ** 2 / 2)
(a) 32 (b) 8.0 (c) 9.5 (d) 32.0
04 What is the output of the expression? 1
country='International'
print(country.split("n"))
(a) ('I', 'ter', 'atio', 'al’)
(b) ['I', 'ter', 'atio', 'al']
(c) ['I', 'n', 'ter', 'n', 'atio', 'n', 'al']
(d) Error
05 What will be the output of the following Python code? 1
print ('1Rn@’. lower ())
(a) n (b) 1rn@ (c) rn (d) r
06 What will be the output of the following Python code? 1
>>>t= (1,2,4,3)
>>>t [1: -1]
(a) (1, 2) (b) (1, 2, 4)
(c) (2, 4) (d) (2, 4, 3)
07 Which of the following statements create a dictionary? 1
(a) d = { }
(b) d = {“john”:40, “peter”:45}
(c) d = {40:” john”, 45:” peter”}
(d) All of the mentioned
08 Which will be the output for the following Python statement 1
L= [10,20,30,40,50]
L=L+5
Print(L)
(a) [10,20,30,40,50,5]
(b) [15,25,35,45,55]
(c) 5,10,20,30,40,50
(d) Error
09 Suppose t = (1, 2, 4, 3), which of the following is incorrect? 1
(a) print (t [3]) (b) t [3] = 45
(c) print(max(t)) (d) print(len(t))
10 Write the missing statement: To write the string "Hello, World!" to a file in Python, 1
use the following code:
with open ('example.txt', 'w') as file:
___________
(a) file.write('Hello, World!') (b) file.read('Hello, World!')
(c) file.readlines('Hello, World!') (d) file.open('Hello, World!')
11 Which of the following is a valid reason for using a 'finally' block? 1
(a) To clean up resources like closing files or releasing memory
(b) To handle different types of exceptions
(c) To break out of a loop
(d) To define a block of code that will never be executed
12 What will be the output of the following code? 1
def outer_function():
x = 10
def inner_function():
x = 20
print ("Inner:", x)
inner_function()
print ("Outer:", x)
outer_function()
(a) Inner: 10, Outer: 20
(b) Inner: 20, Outer: 20
(c) Inner: 10, Outer: 10
(d) Inner: 20, Outer: 10
13 Which keyword is used to remove redundant data from a relation? 1
14 What pattern should be used in the WHERE clause to find all records where the 1
'email' field contains a domain 'example.com'?
(a) LIKE '%@example.com'
(b) LIKE 'example.com%'
(c) LIKE '%example.com%'
(d) LIKE '_example.com'
15 What type of data type is used to store large text values in SQL? 1
(a) VARCHAR (b) INT
(c) TEXT (d) CHAR
16 Which SQL statement would you use to calculate the total sum of the 'price' column 1
in the 'products' table?
(a) SELECT COUNT (price) FROM products;
(b) SELECT SUM (price) FROM products;
(c) SELECT AVG (price) FROM products;
(d) SELECT MAX (price) FROM products;
17 Which of the following protocols is used for secure communication over a computer 1
network?
(a) HTTP (b) FTP
(c) SSH (d) POP
18 Which device is typically used to extend the range of a wireless network by receiving 1
and retransmitting signals?
(a) Hub (b) Router
(c) Repeater (d) Switch
19 Which of the following statements about packet switching is TRUE? 1
(a) Packet switching requires a dedicated path between source and destination.
(b) Packet switching is less efficient than circuit switching.
(c) In packet switching, packets can take different paths to reach the destination.
(d) Packet switching does not support error checking mechanisms.
Q20 and Q21 are Assertion(A) and Reason(R) 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
20 Assertion (A): Default arguments in functions allow some arguments to be omitted 1
when the function is called.
Reason (R): Default arguments must be provided from right to left in the parameter
list.
21 Assertion (A): The GROUP BY clause can be used without any aggregate functions in 1
an SQL query.
Reason (R): The GROUP BY clause alone can be used to eliminate duplicate records.
PART B
22 How do tuples and lists in Python illustrate the concepts of mutable and immutable 2
types?
23 Explain the difference between the '==' operator and the 'is' operator in Python. 2
24 (i) 2
(a) How would you add an element 60 to the end of the list my_list = [10, 20, 30, 40,
50]?
OR
(b) Which method would you use to remove the first occurrence of the value 20
from the list my_list = [10, 20, 30, 20, 40]?
(ii)
(a) How do you find the length of the list my_list = [10, 20, 30, 40, 50]?
OR
(b) How can you insert an element 25 at the second position in the list my_list = [10,
20, 30, 40, 50]?
25 What possible output(s) are expected to be displayed on screen at the time of 2
execution of the program from the following code? Also specify the minimum and
maximum values that can be assigned to the variable End.

import random
Colours = [“VIOLET”, “INDIGO”, “BLUE”, “GREEN”, “YELLOW”, “ORANGE”, “RED”]
End = randrange(2) +3
Begin = randrange(End) + 1
for i in range(Begin,End):
print(Colours[i],end=”&”)

(a) INDIGO&BLUE&GREEN
(b) VIOLET&INDIGO&BLUE&
(c) BLUE&GREEN&YELLOW&
(d) GREEN&YELLOW&ORANGE&
26 Rewrite the following code in Python after removing all syntax error(s) and 2
underline each correction done in the code.
30 = num
for k in range (0, num)
IF k%4==0:
print(k*4)
Else:
print(k+3)
27 (i) Satheesh has created a database “school” and table “student”. Now he wants to 2
view all the databases present in his laptop. Help him to write SQL command for
that, also to view the structure of the table he created.
OR
(ii) Meera got confused with DDL and DML commands. Help her to select only DML
command from the given list of command.
28 (a) Explain how a ring topology functions and mention one scenario where it is 2
particularly useful.
OR
(b) Identify and explain the role of the central component in a star topology
network. How does this component affect network performance?
PART C
29 Write a function in Python to count the number of lines in a text fie ‘EXAM.txt’ 3
which start with an alphabet ‘T’.
OR
Write a function in Python that count the number of “can” words present in a text file
“DETAILS.txt”.
def count_word():
count=0
f=open("textfiles.txt","r")
contents=f.read()
word=contents.split()
for i in word:
if i==’can’:
count+=1
print ("Number of words in the File is:”, count)
f.close( )
count_word( )
30 Julie has created a dictionary containing names and marks as key value pairs of 6 3
students. Write a program, with separate user defined functions to perform the
following operations
Push the key (name of the student) of the dictionary into a stack, where the
corresponding value
(marks) is greater than 75.
Pop and display content of the stack.
For example: If the sample content of the dictionary is as follows
R= {“OM”:76,” JAI”: 45, “BOB”:89, “ALI”:65, “ANU”:90,” TOM”:82}
OR
Alam has a list containing 10 integers. You need to help him create a program with
separate user defined functions to perform the following operations based on this list.
● Traverse the content of the list and push the even numbers into a stack.
● Pop and display the content of the stack.
For Example: If the sample Content of the list is as follows: N=[12, 13, 34, 56, 21,
79, 98, 22, 35, 38] Sample Output of the code should be: 38 22 98 56 34 12
31 Predict the output of the Python code given below: 3
def calculate(str):
text=''
x=range(len(str)-1)
for i in x:
if str[i].isupper():
text+=str[i]
elif str[i].islower():
text+=str[i+1]
else:
text+='@'
return text
start='Pre-board Exam'
final=calculate(start)
print(final)
OR
Predict the output of the Python code given below:
tuple1 = (33, 24, 44, 42, 54 ,65)
list1 =list(tuple1)
new_list = [ ]
for i in list1:
if i>40:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)
PART D
32 (A) 4
T_ID NAME AG SEX DEPT D_O_JOIN SALARY

902 SANDEEP 45 M COMPUTER 10/10/2002 56000


813 SANGEETA 34 F HISTORY 24/9/2010 50000
771 JOEL 48 M ENGLISH 4/5/2001 67900
703 MANVITH 36 M MATHS 27/09/2012 48000
606 NEENA 32 F ENGLISH 23/5/2013 40000
537 ABHILASH 42 M MATHS 6/2/2006 47000
420 MUHSIN 49 M ENGLISH 8/3/2003 70450
412 SUBESH 52 M HINDI 10/11/1999 60500
345 RENJINI 36 F COMPUTER 27/4/2010 45000
218 DEEPTI 28 F HINDI 2/2/2016 40000
160 SHUBHAM 39 M SCIENCE 19/9/2011 45000
Based on the above table, Write SQL command for the following:
i) To show all information about the teacher of maths department
ii) To list name and department whose name starts with letter ‘M’
iii) To display all details of female teacher whose salary in between
35000 and 50000
iv) To display all the List of Subjects taken by the teachers.
OR
(B)Write the outputs of the SQL queries (i) to (iv) based on the relations Teacher and
Placement given below:
BOOK
Book_id Book_name Price Qty Author_id
1001 My first C++ 323 12 204
1002 SQL basics 462 6 202
1003 Thunderbolts 248 10 203
1004 The tears 518 3 204
AUTHOR
Author_id Author_name Country
201 William Hopkins Australia
202 Anita India
203 Anna Roberts USA
204 Brain&Brooke Italy
(i) SELECT Author_id, avg(price) FROMBOOK GROUP BYAuthor_id;
(ii) SELECT MAX (price), MIN (price) FROM BOOK;
(iii) SELECTBook_name,Author_name,countryFROM BOOK B, AUTHOR A
WHERE B.Author_id = A.Author_id AND price>300;
iv) SELECT Author_name FROM AUTHOR WHERE Author_nameLIKE “A%”;
33 Mr. Rao is writing a program to create a csv file “employee.csv” which will contain 4
user name and password for department entries. He has written the following code.
As a programmer, help him to successfully execute the given task.
import ---------------- #statement 1
def add_emp(username,password):
f=open (‘employee.csv’,’----------‘) # statement 2
content=csv.writer(f)
content.writerow([username,password])
f.close()
def read_emp( ):
with open (‘employee.csv’,’r’) as file:
content_reader=csv.-------------------(file) # statement 3
for row in content_reader:
print (row [0], row [1])
file.close( )
add_emp(‘mohan’,’emp123#’)
add_emp(‘ravi’,’emp456#’)
read_emp() #statement 4
i) Name the module he should import in statement 1
ii) In which mode, Mr. Rao should open the file to add record in to the file?
iii) Fill in the blank in statement 3 to read the record from a csv file
iv) What output will he obtain while executing statement 4?
34 Rahul created following table TRAVEL to store the travel details 4

Based on the data given above answer the following questions:


(i) Identify the most appropriate column, which can be considered as Primary key.
(ii) If 3 columns are added and 1rows are deleted from the table TRAVEL, what will
be the new degree and cardinality of the above table?
(iii) Write the statements to:
(a) Insert the following record into the table
110 BIMAL 28-11-2022 200 VOLVO 40
(b) Increase KM travelled by 10 if the VTYPE is VOLVO.
OR (Option for part iii only)
(iii) Write the statements to:
(a) Delete the record of travel of traveler NANDA.
(b) Add a column MILEAGE in the table with data type as
integer
35 The code given below inserts the following record in the table Employee: 4
Empid – integer Name – string salary-float
Note the following to establish connectivity between Python and MYSQL:
• Username is root
• Password is tiger
• The table exists in a MYSQL database named Empolyee.
• The details (Empid, Name, salary) are to be accepted from the user.
Write the following missing statements to complete the code:
Statement 1 – to import correct library
Statement 2 – to form the cursor object
Statement 3 – to execute the command that inserts the record in the table Employee.
Statement 4- to add the record permanently in the database
import _____________ #STATEMENT1
from mysql.connector import Error
connection = mysql.connector.connect(host='localhost', database='Employee',
user='root', password='tiger')
cursor=_______________________#STATEMENT2
empid=int (input ("enter Empid"))
name=input ("enter name")
salary=float (input ("ENTER SALARY"))
result = __________________________#STATEMENT3
___________________________________#STATEMENT4

PART E
36 i) What is the difference between ‘r’ and ‘rb’ mode in Python file? 5
r is used to read text files and rb is used to read binary files
(1 mark for each correct output)
ii) A binary file “STUDENT.DAT” has structure [admission_number,
Name, Percentage]. Write a function countrec( ) in Python that would
read contents of the file “STUDENT.DAT” and display the details of
those students whose percentage is above 90. Also display number of
students scoring above 90%
import pickle
def countrec():
fobj=open(‘student.dat’,’rb’)
num=0
try:
while True:
rec=pickle.load(fobj)
if rec [2]>90:
num=num+1
print (rec [0], rec [1], rec [2])
except:
fobj.close()
return num
37 The USA-based company, Micron, has selected Tata Projects to build the 5
semiconductor assembly and test facility in Sanand Town, near Ahmedabad
in Gujurat. It is planning to set up its different units or campuses in Sanand
Town and its head office campus in New Delhi.

Shortest distance between various locations of Sanand Town blocks


and Head Office at New Delhi:
Training Campus Research Campus 3 KM
Business Campus warehousing 4.5 KM
Manufacturing Campus Research Campus 1.5 KM
Warehousing Training Campus 9.5 KM
Research Campus Business Campus 3.5 KM
Warehousing Campus Research Campus 2.6 KM
Research Campus New Delhi Head Office Campus 962KM

Number of computers installed at various locations are as follows:


Warehousing Campus 20 computers
Research Campus 200 computers
Business Campus 10 computers
Training Campus 25 computers
Manufacturing Campus 15 Computers
Ahmedabad Admin Campus 15 Computers
As a network consultant, you have to suggest the best network related solution for
their issues/problems raised:
(i) Suggest the most appropriate location of the SERVER to get the best and effective
connectivity. Justify your answer.
(ii) Suggest the best wired medium and draw the cable layout (location to location) to
efficiently connect various locations
(iii) Which hardware device will you suggest to connect all the computers within
each location?
(iv) Suggest a system (hardware/software) to prevent unauthorized access to or from
the network.
(v) Which type of network out of the following is formed by connecting the
computers of New Delhi Head Office and Sanand Town Units?
(a) LAN (b) MAN (c) WAN (d) PAN

*****

You might also like