0% found this document useful (0 votes)
135 views11 pages

Class12 Cs Set 1

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)
135 views11 pages

Class12 Cs Set 1

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

XII- PRE-BOARD EXAMINATION 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 five sections- A, B, C, D and E.
• Section A, consists of 18 questions (1 to 18). Each question carries 01 mark.
• Section B, consists of 07 questions (19 to 25). Each question carries 02 marks.
• Section C consists of 05 questions (26 to 30). Each question carries 03 marks.
• Section D consists of 02 questions (31 to 32). Each question carries 04 marks.
• Section E consists of 03 questions (33 to 35). Each question carries 5marks.
• All programming questions are to be answered using Python Language only.
• 15 minutes time has been allotted to read this question paper.

Section – A
Q01. State True or False (1)
“Python is a platform independent, case sensitive and interpreted language”
Q02. Which of the following(s) is/are valid Identifier(s) in Python? (1)
(a) for (b) elif (c) _123 (d) None
Q03. What will be the output of the following Python code? (1)
T1=(1,2,[1,2],3)

T1[2][1]=3.5

print(T1)

(a) (1,2,[3.5,2],3) (b) (1,2,[1,3.5],3) (c) (1,2,[1,2],3.5) (d) Error Message


Q04. What will be the output of the following expression if the value of a=0, b=1 and c=2? print(a (1)
and b or not c )
(a) True (b) False (c) 1 (d) 0
Q05. What should be the output of the following code? (1)
String = “India will be a global player in the digital economy”
Str1= String.title(); Str2=Str1.split() print(Str2[len(Str2)-1:-
3:-1])
(a) [‘Digital’,’Economy’] (b) [‘The’,’Digital’,’Economy’]
(c) [‘economy’,’digital’] (d) [‘Economy’,’Digital’]
Q06. Which of the following statement is incorrect? (1)
(a) A file handle is a reference to a file on disk.

1
Page 1 of 11
(b) File handle is used to read and write data to a file on disk. (c) All the functions that you
perform on a disk file can’t be performed through file handle.
(d) None of these
Q07. Fill in the blank: - (1)
_____________ command is used to add a new column into an existing table in SQL.
(a) UPDATE (b) INSERT (c) ALTER (d) CREATE
Q08. Which of the following command is a DDL command? (1)
(a) SELECT (b) GROUP BY (c) DROP (d) UNIQUE
Q09. Which of the following statement(s) would give an error after executing the following code? (1)
name_marks{'atul':88,'basab':45,'chetan':90} #Statement1
upgrade={} #Statement2
for key in name_marks.keys(): #Statement3
if (name_marks[key]>50): #Statement4
upgrade[key]=name_marks[key] #Statement5
print(upgrade) #Statement6
(a) Statement1 (b) Statement3 (c) Statement4 (d) Statement5
Q10. Fill in the blank: (1)
Number of records/ tuples/ rows in a relation or table of a database is referred to as ________
(a) Domain (b) Degree (c) Cardinality (d) Integrity
Q11. Which of the following statement is not true regarding opening modes of a file? (1)
(a) When you open a file for reading, if the file does not exist, an error occurs.
(b) When you open a file for writing, if the file does not exist, an error does not occur.
(c) When you open a file for appending content, if the file does not exist, an error does not occur.
(d) When you open a file for writing, if the file exists, new content added to the end of the file.
Q12. The __________________ clause is used for pattern matching in MySQL queries. (1)
(a) ALL (b) DESC (c) MATCH (d) LIKE
Q13. A __________________ specifies the distinct address for each resource on the Internet. (1)
(a) FTP (b) WWW (c) URL (d) HTTP
Q14. What will be the output of the following Python code? (1)
print(5<10 and 10<5 or 4<9 and not 3<-3)
(a) True (b) False (c) Error Message (d) None of these
Q15. Which of the following query is incorrect? Assume table EMPLOYEE with attributes (1)
EMPCODE, NAME, SALARY and CITY.
(a) SELECT COUNT(*) FROM EMPLOYEE;
(b) SELECT COUNT(NAME) FROM EMPLOYEE;
(c) SELECT AVG(SALARY) FROM EMPLOYEE;
(d) SELECT MAX(SALARY) AND MEAN(SALARY) FROM EMPLOYEE;
Q16. Which one of the following syntax is correct to establish a connection between Python and (1)
MySQL database using the function connect( ) of mysql.connector package? Assume that import

2
Page 2 of 11
mysql.connector as mycon is imported in the program

.(a) mycon.connect(host = “hostlocal”, user = “root”, password = “MyPass”)


(b) mycon.connect(host = “localhost”, user = “root”, passwd = “MyPass”, database = “test”)

(c) mycon.connect(“host”=“localhost”, “user”= “root”, “passwd”=”MyPass”, “database”= “test”)

(d) mycon.connect(“localhost” = host, “root”=user, “MyPass”=passwd)


Q-17 and Q-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
Q17. Assertion(A): Dictionary is an unordered collection of data values that stores the key: value pair. (1)
Reason(R): Immutable means they cannot be changed after creation.
Q18. Assertion(A): Access mode ‘a’ opens a file for appending content at the end of the file. (1)
Reason(R): The file pointer is at the end of the file if the file exists and opens in write mode.
Section – B
Q19. Manish has designed a Python program to calculate factorial of a number passed as argument, (2)
but he is getting errors while executing the code. Rewrite his code after removing errors and
underline each correction.
def factorial():
fact=1
while N>0:
fact=*N
N=N-1
print(“Factorial’ ,fact)
#main( )
Factorial(5)
Q20. Differentiate between Star Topology and Bus Topology. Write two points of difference. (2)
OR
Write two point of difference between Bridge and Gateway.
Q21. (a) Write the output of when Python string declaration is given as follows: (1)
- Mystr=”I love technology while growing up”
print(Mystr[1:len(Mystr):2])
(1)
(b) Write the output of the code given below:
Student_details = {"name": "aditya", "age": 16}
New=Student_details.copy()
New['address'] = "Mumbai"
print(Student_details);
print(New)

Q22. Explain the Relational Database Management System terminologies- Degree and Attribute of a (2)
relation. Give example to support your answer.

3
Page 3 of 11
Q23. (a) Write the full forms of the following: - (i) FTP (ii) POP (2)
(b) What is MAC address?
Q24. Predict the output of the Python code given below: def (2)
modify(L):
for C in
range(len(L)): if
C%2==1:
L[C]*=2 else:
L[C]//=2
#Main
N=[5,13,47,9]
modify(N)
print(N)
OR
Predict the output of the Python code given below:
T=(1,2,3,4,5,6,7,8,9)
T1=T[2:8:2]
T2=T[-2:-8:-2]
T3=T1+T2
print(T3[::-1])
Q25. Differentiate between WHERE and HAVING clause used in MySQL with appropriate example. (2)
OR
Explain the use of GROUP BY clause in MySQL with an appropriate example.
Section – C
Q26. (a) Consider the following tables – BILLED and ITEM (1+2)

Table: BILLED
BNO NAME CITY
1001 Ashok Delhi
1002 Manish Jaipur
1003 Rahul Lucknow

Table: ITEM
ITEMCODE INAME PRICE
11 HDD 2500
12 Keyboard 850
13 RAM 1100

What will be the output of the following SQL query statement?


SELECT * FROM BILLED, ITEM;
(b) Write the output of the queries (i) to (iv) based on the table EMPLOYEE given below:

4
Page 4 of 11
EMPID NAME DESIGNATION SALARY CITY
101 Harry Manager 90000 Delhi
102 Sam Director 120000 Mumbai
103 Peter Clerk 45000 Delhi
104 Jack Manager 85000 Kolkata
105 Robert Clerk 55000 Mumbai

(i) SELECT DISTINCT DESIGNATION FROM EMPLOYEE;


(ii) SELECT CITY, SUM(Salary) FROM EMPLOYEE GROUP BY CITY HAVING
SALARY > 50000;
(iii)SELECT NAME, SALARY FROM EMPLOYEE WHERE CITY IN
(‘DELHI’,’KOLKATA’) ORDER BY NAME DESC;
(iv) SELECT NAME, SALARY, CITY FROM EMPLOYEE WHERE NAME LIKE ‘H%’
AND SALARY BETWEEN 50000 AND 90000;

Q27. (a) Write a method COUNT_W5() in Python which read all the content of a text file (3)
‘STORY.TXT’ and count &display all those words whose length is 6 character long. For
Example: - If the file content is as follows:
God made the mother earth and the man made countries; These
countries having states and states consists cities.
Then the output of the method will be
Six characters words are: - mother, These, having, states,cities,output,method The
total no of words with length of 6 characters is: 6
OR
(b) Write a function VC_COUNT() in Python, which should read each character of a text file
“THEORY.TXT” and then count and display all the vowels and consonants separately(including
upper cases and small cases).
Example:
If the file content is as follows:
A boy is playing there. There is a playground.
The VC_COUNT() function should display the output as:
Total vowels are: 14
Total consonants are: 22

5
Page 5 of 11
Q28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations ENGINEER and (2+1)
SALARY given below:

Table: ENGINEER

EID NAME AGE DEPARTMENT DOJ GENDER


101 RAVI 34 CODING 2007-09-05 M
102 SUMAN 29 NETWORKING 2010-10-10 F
103 MONU 36 CODING 2003-10-20 M
104 RUPALI 32 ANALYSIS 2012-05-12 F
105 ROHIT 24 TESTING 2017-04-10 M

Table: SALARY
EID BASIC HRA DA
101 40000 3000 2000
102 45000 2500 2500
103 50000 5000 2800
104 35000 3000 1600
105 30000 2500 1200
(i) SELECT DEPARTMENT, COUNT(*) FROM ENGINEER GROUP
BY
DEPARTMENT;
(ii) SELECT MAX(DOJ), MIN(DOJ) FROM ENGINEER;
(iii) SELECT NAME, DEPARTMENT, (BASIC+HRA+DA) AS
“TOTALSALARY”
FROM ENGINEER, SALARY WHERE ENGINEER.EID =SALARY.EID;
(iv) SELECT NAME, HRA FROM ENGINEER E, SALARY S WHERE
E.EID=S.EID
AND GENDER = ’F’;
(b) Write a command to view the structure of a table.
Q29. Write a function INTERCHANGE(L), where L is the list of elements (3)
passed as argument to the function. The function returns another list
named ‘ChangedList’ that contain values interchanged as the even index
value with next consecutive odd index value of the L. For example:
If L contains [25,30,35,40,45]
The ChangedList will have [30,25,40,35,45 ]

6
Page 6 of 11
Q30. A list named as Record contains following format of for students: (3)
[student_name, class, city]. Write the following user defined functions to
perform given operations on the stack named
‘Record’:
(i) Push_record(Record) – To pass the list Record = [ ['Rahul', 12,'Delhi'],
[‘Kohli',11,'Mumbai'], ['Rohit',12,'Delhi'] ] and then Push an object
containing Student name, Class and City of student belongs to ‘Delhi’ to
the stack Record and display and return the contents of stack (ii)
Pop_record(Record) – To pass following Record [[“Rohit”,”12”,”Delhi”]
[“Rahul”,
12,”Delhi”] ] and then to Pop all the objects from the stack and at last display
“Stack Empty”
when there is no student record in the stack. Thus the output should be: -
[“Rohit”,”12”,”Delhi”]
[“Rahul”, 12,”Delhi”]
Stack Empty
OR
A list of numbers is used to populate the contents of a stack using a function push(stack, data)
where stack is an empty list and data is the list of numbers. The function should push all the
numbers that are even to the stack. Also write the function pop() that removes the top element of
the stack on its each call.
Section – D
Q31. Manoj is working in a mobile shop and assigned a task to create a table MOBILES with (1+1+2)
record of mobiles as Mobile code, Model, Company, Price and Date of Launch. After creation of the
table, he has entered data of 5 mobiles in the MOBILES table.
MOBILES
MCODE MODEL COMPANY PRICE DATE_OF_LAUNCH
M01 9PRO REALME 17000 2021-01-01
M02 NOTE11 MI 21000 2021-10-12
M03 10S MI 14000 2022-02-05
M04 NARZO50 REALME 13000 2020-05-01
M05 iPHONE12 APPLE 70000 2021-07-01

Based on the data given above answer the following questions:


(i) Identify the most appropriate column, which can be considered as Primary key.

7
Page 7 of 11
(ii) Write the degree and cardinality of the above table, after removing one column and two
more record added to the table.
(iii) Write the statements to:
(a) Add a new column GST with data type integer to the table.
(b) Insert the value of GST in the new column as 18% of PRICE.
OR (Option for part iii only)
(iii) Write the statements to:
(a) To insert a new record of mobile as MobileCode – M06, Company Apple, Model-
iPHONE13, Price-110000 and Date of launch – ‘2022-03-01’.
(b) To delete the record of mobile with model as NARZO50.
Q32. Arun, during Practical Examination of Computer Science, has been assigned an (1+1+2) incomplete
search() function to search in a pickled file student.dat. The File student.dat is created by his Teacher
and the following information is known about the file.
• File contains details of students in [Rollno, Name, Marks] format.

• File contains details of 10 students (i.e. from Rollno 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 7.

import _________________ # Statement1 def


search( ):
f=______________________ #Statement2
found=0 while True: try:
rec=pickle._____________ #Statement3
if(_________________): #Statement4
print(rec); found=1 except: break if
(found==0):
print("Record not found")
(i) Which module should be imported in the program? (Statement 1)
(ii) Write the correct statement required to open a file student.dat. (Statement 2)
(iii) Which statement should arun fill in Statement 3 to read the data from the binary file,
student.dat and in Statement 4 to match the Rollno.
Section – E
Q33. Signature Training Institute is planning to set up its centre in Jaipur with four specialized blocks (5) for
MBBS, MBA, BTECH and ADMIN. The physical distance between these blocks and the number of

8
Page 8 of 11
computers to be installed in each block is given below. The Head Quarter of the Institute is in Delhi.
You as a Network expert have to answer the queries raised by their board of directors as given (i) to (v).
JAIPUR CAMPUS

MBA ADMIN

MBBS BTECH

Distance between blocks in meter:


MBBS to MBA - 60
MBBS to ADMIN - 190
MBBS to BTECH - 110
MBA to BTECH - 120
MBA to ADMIN - 50
No of computers to be installed in each Block:
ADMIN - 50
MBBS - 15
MBA - 25
BTECH - 40

(i) Suggest the most appropriate block to house the SERVER in Jaipur Campus to get the
best and effective connectivity. Justify your answer.
(ii) Suggest a device/software to be installed in Jaipur campus to take care of data security.
(iii) Suggest the best wired medium and draw the cable layout to economically connect all the
blocks with the campus.
(iv) Suggest the placement of the following devices with appropriate reasons:
(a) Switch / Hub (b) Repeater
(v) Suggest a protocol that shall be needed to provide video conferencing solution between
Jaipur campus and Delhi Head Quarter.
Please note that there is internal choice in Q34 & Q35.
Q34. (a) Write the output of the code given below: (2+3) def Funstr(S):
T="" for i
in S: if
i.isdigit():
T=T+i
return T

A="Comp.Sc.- 083"
B=Funstr(A) print(A,'\n',B,
sep="#")
9
Page 9 of 11
(b) The code given below inserts the following record in the table employee:
EmpNo – integer
EmpName – string
Salary – integer
City – string
Note the following to establish connectivity between Python and MYSQL:
• Username is root Password is tiger
• The table exists in a MYSQL database named COMPANY.
• The details (EmpNo, EmpName, Salary and City) are to be accepted from the user.

Write the following missing statements to complete the code:


Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table Employee.
Statement 3 - to add the record permanently in the database

import mysql.connector as mysql def sql_data():


con1=mysql.connect(host="localhost",user="root", passwd="tiger", database=
"company")
mycursor=_________________ #Statement 1
EmpNo=int(input("Enter Employee Number : "))
EmpName=input("Enter Employee Name : ")
Salary=int(input("Enter Employee Salary: "))
City=input("Enter Employee City Name: "))
query="insert into Employee values({},'{}',{},’{}’)".format(EmpNo,EmpName, Salary,City)
______________________ #Statement 2
______________________ # Statement 3 print("Data
Added successfully")
OR
(a) Predict the output of the code given below: def ListChange(L): for
i in range(len(L)): if L[i]%2==0: L[i]=L[i]*2 if
L[i]%3==0: L[i]=L[i]*3 if L[i]%5==0: L[i]=L[i]*5
L=[3,4,5,9]
ListChange(L) for
i in L:
print(i, end="$")
(b) The code given below reads the following record from the table named
Product and displays only those records whosepriceis greater than
500:
PNo – integer

10
Page 10 of 11
PName – string Price
– integer
Note the following to establish connectivity between Python and MYSQL:
• Username is root
• Password is tiger
• The table exists in a MYSQL database named school.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those products whose Priceare
greater than 500.
Statement 3- to read the complete result of the query (records whose price are greater than
500) into the object named data, from the table Product in the database. import
mysql.connector as mysql def sql_data():
con1=mysql.connect(host="localhost",user="root",passwd="tiger", database="ABCD")
mycursor=_______________ #Statement 1 print("Product detail whose price greater
than 500 are : ")
_________________________ #Statement 2
data=__________________ #Statement 3 for
i in data: print(i) print()
Q35. How CSV files are different from normal text files? (5)
Write a program in Python that defines and calls the following user defined functions:

(i) INSERT() – To accept and add data of a Student to a CSV file ‘Sdetails.csv’. Each record
consists of a list with field elements as RollNo, Name, Class and Marks to store roll
number of students, name of student, class and marks obtained by the student.
(ii) COUNTROW() – To count the number of records present in the CSV file named
‘Sdetails.csv’.
OR

Write syntax to create a reader object and write object to read and write the content of a CSV

file. Write a Program in Python that defines and calls the following user defined functions:

(i) ADD() – To accept and add data of an employee to a CSV file ‘empdata.csv’. Each record

consists of a list with field elements as Eid, Ename, Salary and City to store employee id ,

employee name, employee salary and city.

(ii) SEARCH()- To display the records of the employees whose salary is more than 50000.

***** End of Paper*****

11
Page 11 of 11

You might also like