You are on page 1of 11

Subject-Computer Science (083)

Year: 2022-23
Class 12

Duration: 3 hours Max Marks: 70

General Instructions:

1. This question paper contains five sections, Section A to E.

2. All questions are compulsory.

3. Section A has 18 questions carrying 01 mark each.

4. Section B has 07 Very Short Answer type questions carrying 02 marks each.

5. Section C has 05 Short Answer type questions carrying 03 marks each.

6. Section D has 03 Long Answer type questions carrying 05 marks each.

7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35 against part c only.

ps
8. All programming questions are to be answered using Python Language only.
Ki

© Kips Learning Pvt. Ltd 2023


Part-A

1. State True or False: 1


Operator Associativity defines the order in which operators of the same precedence are
evaluated.

2. The statement that helps to terminate the loop is called ______________. 1


a) continue
b) break
c) exit
d) pass

3. Which of the following options will not result in an error when performed on tuples in Python 1
where tupl=(5,2,7,0,3)?

a) tupl[1]=2
b) tupl.append(2)
c) tupl1=tupl+tupl
d) tupl.sort()

4. What is the value returned by find() function for an unsuccessful search of sequence in the given 1
string?
a) Error
b) False

5.
c) 0
d) -1

car = {
ps
Choose the appropriate statement to change the "year" value from 2000 to 2015.

"brand": "Maruti Suzuki",


"model": "Dzire",
"year": 2000
1

}
Ki
a) car["year"] = 2015
b) car.year = 2015
c) car.year[2015]
d) year = 2015

6. The ________________ method returns the file object’s current position. 1


a) seek(curr)
b) tell()
c) loc()
d) curr()

7. To give a temporary name to a table or a column in a table for more readability, what is used? 1
a) SQL Wildcards
b) SQL aliases
c) SQL LIKES
d) SQL Comments

8. By using an aggregate function, the __________clause filters the results of the GROUP BY 1
clause.
a) HAVING

© Kips Learning Pvt. Ltd 2023


b) ORDER BY
c) DISTINCT
d) GROUP BY

9. What is the meaning of “ORDER BY” clause in MySQL? 1


a) Sorting your result set using column data
b) Aggregation of fields
c) Sorting your result set using row data
d) None of the above
10. 1
What will happen when you run the following MySQL statement?

SELECT e.emp_id, e.fname,e.lname,d.name


FROM employee e INNER JOIN department d
ON e.dept_id=e.dept_id;

a) Error
b) No Error

11. To read two characters from a file object infile, we use ____________. 1
a) infile.read(2)

12.
ps
b) infile.read(0,3)
c) infile.readline(2)
d) infile.readlines()

“SELECT” clause cannot be used without which clause in MySQL?


a) FROM
b) WHERE
c) ORDER BY
d) All of the above
1

13. In an environment with many high-voltage devices, the best transmission medium would be 1
Ki
_______.
a) Twisted-pair cable
b) Coaxial cable
c) Optical fibre
d) None of these

14. Observe the given SQL query and choose the correct option. 1

SELECT branch_name, COUNT (DISTINCT customer_name)


FROM depositor, account
WHERE depositor.account_number = account.account_number
GROUP BY branch_id

a) The query is syntactically correct, but gives the wrong answer.


b) The query is syntactically wrong.
c) The query is syntactically correct and gives the correct answer.
d) The query contains one or more wrongly named clauses.

15. State True or False: 1

SQL does not permit distinct with count(*)

© Kips Learning Pvt. Ltd 2023


a) True
b) False

16. Which connector is used to link database with Python? 1

a) Mysql-connector
b) Connector-Python
c) Python-connector
d) Mysql-Python-connector

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 , but 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): The scope refers to different parts of the function and program within which a 1
variable or value is legal and accessible.
Reason (R): Global is a keyword to create global variable.

18. Assertion (A): The pickling module consist of two main functions. load() is used during the 1

19.
ps
pickling process, whereas dump() is used during unpickling process.
Reason (R): You can use load() and dump() function by adding pickle module. You can use
"import pickle" statement to include the pickle module in your program.

Part- B

Sejal has written a code to print prime numbers between given range. Her code is having errors.
Rewrite the correct code and underline the corrections made.
2

def prime(lower,up)
Print("Prime numbers between", lower, "and", upper, are:)
Ki
for num in range(lower, upper + 1):
if num > 1:
for i in range(2, num)
if (num % i) = 0:
break:
else:
print(num)
def prime(10,20)

20. Your friend wishes to install a wireless network in his office. Explain to him the difference 2
between guided and unguided media.
OR

What is a network? Write any two advantages of a network.

21. Fill the blanks in the following code: 2

© Kips Learning Pvt. Ltd 2023


import ________#statement 1
with open("Text.csv", 'r') as ________#statement 2
L = csv.reader(fin)
for line in ___: #statement 3
print(___________) #statement 4

Choose the correct option to fill in statement 1,2,3,4, respectively.


a) csv, fin, L, line
b) CSV , f , fin , line
c) CSV , fin , l , line
d) None of these

22. What is the difference between the primary key and unique key? 2

23. (a) Write the full forms of the following: 2


(i) SMTP (ii) URL
(b) What is the use of VoIP?

24.

ps
Predict the output of the Python code given below:
dic1={10:0, 20:2}
dic2={30:3, 40:4}
dic3={50:5,60:6}
dic4 = {}
for d in (dic1, dic2, dic3):
dic4.update(d)
print(dic4)

OR
2
Ki
def Display(str):
m=""
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"#"
print(m)
Display('Fun@Python3.0')

25. Differentiate between fetchone() and fetchall() methods with suitable examples for each. 2
OR
Differentiate between degree and cardinality.

© Kips Learning Pvt. Ltd 2023


Part- C

26. 1+1+
a) 1

What will be the output of the following statement?

SELECT *
FROM foods
NATURAL JOIN company;

b) ps
Twinkle is using a table EMPLOYEE. It has the following columns:
Code, Name, Salary, Dept code. She wants to display maximum salary Department wise.
She wrote the following command:

SELECT Dept code, Max(Salary)


FROM EMPLOYEE:

But she did not get the desired result.


Rewrite the above query with necessary change to help her get the desired output.
Ki
c) What is the purpose of DDL Language?

27. Write a function in Python to count and display the total number of words in a text file. 3
OR/
Write a function display_words() in Python to read lines from a text file "poem.txt", and display
those words, which are less than 4 characters.

28. a) Write SQL queries for (i) to (iv), which are based on the following tables. 3
TABLE : ACCOUNT

© Kips Learning Pvt. Ltd 2023


TABLE : TRANSACT

i. To display the details of all the transactions of TYPE Deposit from Table TRANSACT.
ii. To display the ANO and AMOUNT of all Deposits and Withdrawals done in the month
of October 2017 from table TRANSACT.
iii. To display the last date of transaction (DOT) from the table TRANSACT for the
Accounts having ANO as 103.
iv. To display all ANO, ANAME and DOT of those persons from tables ACCOUNT and
TRANSACT who have done transactions less than or equal to 3000.

b) Differentiate between DELETE and DROP table commands.

29. Write a Python program using the function to accept characters in a list, then find and display 3

30.
ps
vowels present in the list.

Write a menu-based program to add, delete, and display the record of hostel using list as stack
data structure in Python. Record of hostel contains the following fields: Hostel number, Total
Students, and Total Rooms.

OR
3
Ki
Write push(rollno) and pop() method in Python:
a) push(rollno) --add roll number in Stack.
b) pop() --- remove roll number from Stack.

Part- D
31. Western School in Mumbai is starting up the network between its different wings. There are four
buildings, named as SENIOR, JUNIOR, ADMIN, and HOSTEL as shown below:

The distance between various buildings is as follows:

© Kips Learning Pvt. Ltd 2023


Number of Computers in Each Building:

1
1
a) Suggest the cable layout of connections between the buildings.
b) Suggest the most suitable place (i.e., building) to house the server of this school and 1

ps
provide a suitable reason.
c) Suggest the placement of the following devices with justification:
• Repeater
• Hub/Switch
d) The organisation also has an inquiry office in another city about 50-60 km away in a hilly
region. Suggest the suitable transmission media to interconnect to school and inquiry
office out of the following:
• Fibre optic cable
• Microwave
• Radio waves
1

e) Suggest a protocol that shall be needed to provide video conferencing solution between
Ki
various buildings.

32. a) Find the output of the following: 2+3

def calcSquare(a):
a = power(a, 2)
return a
def power (b , p):
r = b**p
return r
n=5
result = calcSquare(n)
print(result)

b) Write the steps to perform an Insert query in database connectivity application.


Table ‘student’ values are rollno, name, age (10,’Raman’,26).

RollNo – integer
Name – string

© Kips Learning Pvt. Ltd 2023


Age – integer

Note the following to establish connectivity between Python and MYSQL:


• Username is root
• Password is 1234
• The table exists in a MYSQL database, named school.
• The details (RollNo, Name, Class, and Age) 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 Student
Statement 3- to add the record permanently in the database

import mysql.connector as mydb


conn= mydb.connect(host=”localhost”, user=”root”, passwd=”1234”)
cur=_____________ #Statement 1
cur.execute______________________#Statement 2
_______________________ #Statement 3
print("Data Added successfully")

OR

ps
a) Predict the output of the code given below:

s="PyThontest2"
n = len(s)
m=""
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m +s[i-1]
elif (s[i].isupper()):
Ki
m = m + s[i].lower()
else:
m = m +'&'
print(m)

b) Write the steps to perform an Insert query in database connectivity application.


Table ‘student’ values are rollno, name, age (10,’Raman’,26)

RollNo – integer
Name – string
Age – integer

Note the following to establish connectivity between Python and MYSQL:


• Username is root
• Password is 1234
• The table exists in a MYSQL database named school.
• The details (RollNo, Name, Clas and Age) are to be accepted from the user.

Write the following missing statements to fetch all records of a table Student at run time:
Statement 1 – to form the cursor object

© Kips Learning Pvt. Ltd 2023


Statement 2 – to execute the command that fetch all records of a table Student .
Statement 3- to fetch all records

import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="
123" ,database="school")
mycursor=_________________________# Statement 1
mycursor._____________________ # Statement 2
myrecords=___________________ # Statement 3
for x in myrecords:
print (x)

33. Write a program to search the record from “data.csv” according to the admission number input 5
from the user. The structure of record saved in “data.csv” is Adm_no, Name, Class, Section, and
Marks. Also, write a function ADD() to accept and add data of an employee to a CSV file
‘data.csv’. Each record consists of a list with field elements as Adm_no, Name, Class, Section, and
Marks, respectively.

OR

1, Amit, 87
2, Aman, 98
3, Pooja, 85
ps
a) Give any one point of difference between a binary file and a csv file.
b) Write a program to show the details of the student who scored the highest marks. Data
stored in “Details.csv” is given below:

4, Sandhya, 80

PART E
Ki
34. 1. Write SQL queries for (i) to (iv), which are based on the tables Account and Transact. 4

TABLE : ACCOUNT

TABLE : TRANSACT

© Kips Learning Pvt. Ltd 2023


i) To display the details of all transactions of TYPE Deposit from Table TRANSACT.
ii) To display the ANO and AMOUNT of all Deposits and Withdrawals done in the month
of October 2017 from table TRANSACT.
iii) To display the last date of transaction (DOT) from the table TRANSACT for the
Accounts having ANO as 103.
iv) To display all ANO, ANAME, and DOT of those persons from tables ACCOUNT and
TRANSACT who have done transactions less than or equal to 3000.

35. Harsh is working on his class project and wrote the following program to write Name and Roll 4
numbers into a binary file. As a Python expert, help him to complete the following code based on
the requirement given above:

import _________________#statement 1
with open ("file.dat", "wb") as ____________#Statement 2:
while True:
op = int (input ("Enter 1 to add data, 0 to quit"))
if (op == 1):
name = input ("Enter name : ")
rollno = int (input ("Roll no : "))
____________._______([name,rollno],F1) # statement 3

ps
elif op == 0:
break

1. Which module should be imported in the program? (Statement 1)

2. Choose the appropriate answer to fill in statement 2


a) F1
b) op
c) name
d) rollno
Ki
3. Write the appropriate function in statement 3 to load the data.
4. Write the difference between loads() and dumps() function.

© Kips Learning Pvt. Ltd 2023

You might also like