Puterscience SQP Set3

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Sample Question Paper - III

Class: XII Session: 2024-25


Computer Science (083)
Maximum Marks: 70 Time Allowed: 3 hours
General Instructions:
● This question paper contains 37 questions.
● All questions are compulsory. However, internal choices have been provided in somequestions.
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.
SECTION A
1. State whether True or False: 1
Variable names can begin with the _ symbol.
2. Identify which of the following is an invalid data type in Python: 1
(a) int (b) float (c) super (d) None
3. Consider the following code: 1
dict1 = {‘Mohan’: 95, ‘Ram’: 89, ‘Suhel’: 92, ‘Saritha’: 85}
What suitable code should be written to return a list of values in dict1 ?
4. Consider the following expression: not True and False or not False 1
Which of the following will be the output:
a) True b) False c) None d) NULL
5. Select the correct output of the following code: 1
>>>str1 = ‘India is a Great Country’
>>>str1.split(‘a’)
a) [‘India’,’is’,’a’,’Great’,’Country’] b) [‘India’, ’is’, ’Great’, ’Country’]
c) [‘Indi’, ’is’, ’Gre’, ’t Country’] d) [‘Indi’, ’is’, ’Gre’, ’t’, ‘Country’]
6. Which of the following is an invalid access mode for text files: 1
(a) W (b) a+ (c) ab (d) r
7. Fill in the blanks: 1
command is used to add a new column in the table in SQL.
Ans: ALTER
8. Which of the following will display all the tables in a database: 1
a) SELECT * FROM <tablename>; b) DISPLAY TABLES;
c) SHOW TABLES; d) USE TABLES;

9. Which of the following will be the output of the code: 1


mySubject = “Computer Science”
print(mySubject[:3] + mySubject[3:])
a) Com b) puter Science
c) Computer Science d) Science Computer
10. Choose the correct option: 1
is the number of columns in a table and is the number of rows in the table.
a) Cardinality, Degree b) Degree, Cardinality
c) Domain, Range d) Attribute, Tuple

Page 1 of 7
11. The correct syntax of load( ) is: 1
a) <objectvariable>=pickle.load(<fileobject>) b) pickle.load(<fileobject>, <objectvariable>)
c) <fileobject>.load(<objectvariable>) d) <objectvariable> = <fileobject>.load( )

12. The clause is used to display result of an SQL query in ascending or descending order 1
with respect to specified attribute values
13. Fill in the blank: 1
is the protocol used for transferring files from one machine toanother.
a) HTTP b) FTP
c) SMTP d) VOIP

14. How will the following expression be evaluated in Python? 1


2 + 9 * ( ( 3 * 12) – 8 ) / 10
a) 29.2 b) 25.2
c) 27.2 d) 27
15. Which function is used to display the sum of values in a specified column ? 1
a) COUNT(column) b) TOTAL(column)
c) SUM(column) d) ADD(column)
16. To open a connector to the MySQL database, which statement is used to connect with MySQL ? 1
a) Connector b) connect c) password d) username
17. Which of the following statement(s) would give an error after executing the following code?
S="Welcome to class XII" # Statement 1
print(S) # Statement 2
S="Thank you" # Statement 3
S[0]= '@' # Statement 4
S=S+"Thank you" # Statement 5
(a) Statement 3 (b) Statement 4 (c) Statement 5 (d) Statement 4 and 5
18. Consider the following operation performed on a stack of size 5.
Push(1)
Pop()
Push(2)
Push(3)
Pop()
Push(4)
Pop()
Pop()
Push(5)
After the competition of all operation, the number of elements present is stack are
(a) 1 (b) 2 (c) 3 (d) 4
19. Which keyword is used to catch exceptions in Python?
a) try (b) catch (c) except (d) d) handle
Q20 and 21 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
20. Assertion (A) : A variable defined outside any function or any block is known as a global variable. 1
Reason (R) : A variable defined inside any function or a block is known as a local variable.
Ans: (b) Both A and R are true and R is not the correct explanation for A

Page 2 of 7
21. Assertion (A) : The tell( ) method returns an integer that specifies the current position of the file 1
object in the file.
Reason (R) : Offset can have any of the three values – 0, 1 and 2
SECTION B
22. Observe the following Python code very carefully and rewrite it after removing all syntactical errors 2
with each correction underlined.
DEF result_even( ):
x = input(“Enter a number”)if (x % 2 = 0) :
print (“You entered an even number”)else:
print(“Number is odd”)
even ( )
23. Write two points of difference between LAN and WAN. 2
(OR)
Write two points of difference between HTTP and SMTP.
24 (a) Given is a Python string declaration: 1
str1="!!Welcome to Python!!"
Write the output of: 1
print(str1[::-2])
(b) Write the output of the code given below:
dict1 = {"name": "Suman", "age": 36}
dict1['age'] = 27
dict1['address'] = "Chennai"
print(dict1.keys())
25. Write a Python program that executes division and handles an ArithmeticError exception if there is 2
an arithmetic error.
26. (a) Expand the following: 1
i) XML ii) HTML
(b) What is the use of PPP in computer networks? 1
27. (a) Write two points of difference between LAN and WAN 2
(OR)
(b) Write two points of difference between HTTP AND SMTP
28. Differentiate between COUNT(*) and SUM( ) functions in SQL with appropriate example. 2
(OR)
Categorize the following commands as DDL or DML: CREATE, DROP, UPDATE, INSERT
SECTION C
29. Write a function in python to count the number lines in a text file ‘Country.txt’ which is starting 1+2
with an alphabet ‘W’ or ‘H’. If the filecontents are as follows:
Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.
The output of the function should be:W or w : 1
H or h : 2
(OR)
Write a user defined function countwords( ) to display the total number of words present in the text
file “Quotes.Txt”. If the text file has the following data written in it:

Living a life you can be proud of doing your best


Spending your time with people and activities that are important to you
Standing up for things that are right even when it’s hard
Becoming the best version of you

Page 3 of 7
The countwords() function should display the output as:
Total number of words : 40
30. A list, NList contains following record as list elements: 3
[City, Country, distance from Delhi]
Each of these records are nested together to form a nested list. Write the following user defined
functions in Pythons to perform the specified operations on the stack named travel.
(a) Push_element(travel,NList): It takes the nested list as an argument and pushes a list object
containing name of the city and country, which are not in India and distance is less than 3500 km
from Delhi.
(b) Pop_element(travel): It pops the objects from the stack and displays them. Also, the function
should display "Stack Empty: when there are no elements in the stack.
(c) peep(travel): This function displays the topmost element of the stack without deleting it. If the
stack is empty, the function should display ‘None’.
For example:
If the nested list contains the following data:
NList=[["New York", "USA",11734],["Naypyidaw","Myanmar", 3219], ["Dubai","UAE",2194],
["London","England",6693], ["Gangtok","India",1580], ["Columbo","Sri Lanka",3405]]
The stack should contain:
["Naypyidaw","Myanmar"]
["Dubai","UAE"]
["Columbo","Sri Lanka"]
The output should be:
["Columbo","Sri Lanka"]
["Dubai","UAE"]
["Naypyidaw","Myanmar"]
Stack Empty
OR
Write a function in Python(SItem) where, SItem is a dictionary containing the details of stationary
items - {Sname:Price}.
(a) Push(SItem, Price): The function should push the names of those items in the stack who have
price greater than 75. Also display the count of elements pushed into the stack.
(b) Pop(SItem): this function pops the topmost book record from the stack and returns it. If the stack
is already empty, the function should display “None”
(c) Traverse(SItem) : This function is show all element of the stack. If the stack is empty, the
function should display “Empty Stack”

For example:
If the dictionary contains the following data:
Ditem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25}
The stack should contain
Notebook
Pen
The output should be
The count of elements in the stack is 2
31. Predict the output of the following Python code: 3
def Bigger(N1,N2):
if N1>N2:
return N1
else:
return N2
L=[32,10,21,54,43]
Page 4 of 7
for c in range (4,0,-1):
a=L[c]
b=L[c-1]
print(Bigger(a,b),'@', end=' ')

(OR)

Predict the output of the following Python code:


tup1 = ("George", "Anderson", "Mike", "Luke", "Amanda")
list1 =list(tup1)
list2 = []
for i in list1:
if i[-1]=="e":
list2.append(i)
tup2 = tuple(list2)
print(tup2)

SECTION D
32. As part of Fit India Campaign, Suresh has started a juice shop that serveshealthy juices. As his 1+1+2
database administrator, answer the following questions based on the data given in the table below.
Table : HEALTHYDRINKS

(i) Insert the following record into the table


DrinkCode – 107, Dname – Santara Special, Price – 25.00, Calorie – 130
(ii) Increase the price of the juices by 3% whose name begins with ‘A’.
(iii) Delete the record of those juices having calories more than 140.
(iv) Add a column Vitamins in the table with datatype as varchar with 20characters.
OR
(b) Write the output of the queries (i) to (iv) based on the table given below:
Table: Activity
PID PARTICIPANT GRADE EVENT POINTS EVENTDATE HOUSE
101 Ajay Devgan A Running 200 2022-02-03 Gandhi
102 John Abraham Hopping Bag 300 2021-12-02 Bose
103 Sunny Deol B Skipping 200 2019-09-23 Gandhi
104 Akshay Kumar A Bean Bag 250 2020-11-14 Bhagat
105 Juhi Chawla A Obstacle 350 2022-03-17 Bose
106 MadhuriDixit Egg & Spoon 200 2021-10-15 Bose
(i) SELECT PARTICIPANT, POINTS FROM Activity ORDER BY POINTS DESC;
(ii) SELECT HOUSE, COUNT(PARTICIPANT) FROM Activity GROUPBY HOUSE;
(iii) SELECT DISTINCT POINTS FROM Activity;
(iv) SELECT PID,EVENTDATE FROM Activity WHEREEVENT=”Running” OR
EVENT=”Skipping”;
33. Write a function def display( ) in Python to read all the records from the file Inventory.csv which 4
stores the records of various products such as Television, Refrigerator, Air-conditioner, etc. under

Page 5 of 7
different fields as mentioned below:
Code Item Company Price Quantity
T01 Television LG 43000 15
T02 Television Sony 55000 20
F01 Refrigerator LG 35000 10
(i) Now display the details of all televisions of various comparisons from the file.
(ii) Count the number of records those item quantity more than 20.
34. In a Database Company, there are two tables given below: 4
Table: SALES
SALESMANID NAME SALES LOCATIONID
S1 ANITA SINGH ARIRA 250000 102
S2 Y.P. SINGH 1300000 101
S3 TINA JAISWAL 1400000 103
S4 GURDEEO SINGH 1250000 102
S5 SIMI FAIZAL 1450000 103
Table: LOCATION
LOCATIONID LOCATIONNAME
101 Delhi
102 Mumbai
103 Kolkata
104 Chennai
Write SQL queries for the following :
(i) To display SalesmanID, Name of salesman, LocationID with corresponding location names.
(ii) To display name of salesmen, sales and corresponding location names who have achieved Sales
more than 1300000.
(iii) To display names of those salesmen who have ‘SINGH’ in their names.
(iv) (A) Indentify Primary key in the table SALES. Give reason for your choice.
OR
(B) Write SQL command to change the LocationID to 104 of the Salesman with ID as S3 in the
table ‘SALES’.
35. The code given below inserts_and_show() 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.
SECTION E
36. Python University is setting up its academic blocks at Chennai 5
and is planning to set up a network. The University has 3 academic blocks and one Human Resource
Center as shown in the diagram below:

Page 6 of 7
Center to Center distances between various blocks/center is as follows:

No. of computers in each block/center is given above.


a) Suggest the most suitable place (i.e., Block/Center) to install the server ofthis University with
a suitable reason.
b) Suggest an ideal layout for connecting these blocks/centers for a wired connectivity.
c) Which device will you suggest to be placed/installed in each of these blocks/centers to
efficiently connect all the computers within these blocks/centers.
d) Suggest the placement of a Repeater in the network with justification.
e) The university is planning to connect its admission office in Delhi, whichis more than 1250km
from university. Which type of network out of LAN, MAN, or WAN will be formed? Justify
your answer.
37. A binary file players.dat, containing records of following list format: [code, name, country and total 5
runs]
(i)Write a python function that display all records where player name starts from 'A'
(ii)Write a python function that accept country as an argument and count and display the number of
players of that country.
(iii)Write a python function that add one record at the end of file.

Page 7 of 7

You might also like