Class 12 TH Computer Science PRE BOARD 1

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

No.

of Printed Pages : 12 (Set-1) AGRO-I

IPre-Board Examination, 2023-24


Sub: Conmputer Science (083)
Time :3.00 Hrs. I Class - XII | M. M. :70

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

Q1. What will be the evaluation of python expression - 2*2**3**2 +2 1

a) 130 b) 1026

c) 258 d) 68

Q2. Which of the followingis not a valid identifier in python? 1

a) Def b) false

True d) print
Q3. Given a string s ="Happy Diwali',what will be the value of string slice s[:-21? 1

a) iai pa b) HpyDwl
c) lwDypH d) iaiypH
Q4 Which among the following is/are mutable data types in python? 1

a) list b) tuple
c) string d) boolean
Computer Science/XTISet-/AGRO-I | P.T.O.
Which python statement will delete all elements of adictionary named d
a) ddeleteçal) b) ddelete( )
dclear) d) dempty)
Q6 The retun type of the printo tunction is:
string b) integer

list d) None
result in an
Q7 Consider atuple t (10, 15, (20, 25), 30, 35), ldentity the statement that will
1

printt2) b) t(20) =200


(3) 300 d) print(len())
Q8 Which of the following symbols is not an operator in python?
a) b)
) $
Which of the followingtransmission media does not use electric signals to carry data? 1
Q9
Twisted Pair Cable b) Optical Fiber
Co axial cable d) None of the above

Q10. Which of the following connector is used for Ethemet cables in a LAN?
a) RJ11 b) RJ45

c) ETHO d) FConnector
1
Q11. Which two of the following queries are not valid in MySQL?
a select gender, count(") form students having age >15;
b) select gender, count() from students where age>15 group by gender;
select gender, sum(age) from students group by gender having sum(age)>25;
d) select gender, max(age) from students group by gender order by max(age);
Q12. Which of the following is not a DDL Command in SQL?
a) ALTER b) UPDATE

c) DROP d) CREATE
Computer ScienceNTISer-VAGRO-I
I31
Q13. Ifa MySQL table named Ahas 5 columns and 6 rows and another table Bhas 3 columns and

4rows, then what will be the degree and cardinality of the cartesian product of Aand B? 1
a) 15, 24 b) 8, 10
8, 24 d) 5,24
Q14. Which of the following is the unit used to measure data transfer rate of a computer
network? 1

a) mps b) bps
c) Hertz (Hz) d) None of these

Q15. Which of the following keyword is used along with try block to handle exceptions. 1

a) catch b) handle

) follow d) except
Q16. Which of the following are not correct ways of opening a text file in python? 1

a F= open(story.txt, 'read') b) with open(story.txt) as F:


) F= open('story.txt','a+') d) Open() = story.txt'
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice
as:

Both Aand Rare true and Ris the correct explanation for A
b Both Aand Rare true and Ris not the correct explanation for A
A is True but R is False

d) A is false but R is True

Q17. Answer with (a) to (d) given above. 1

Assertion (A): Afunction definition can have zero parameters/formal arguments.


Reasoning (R): Parenthesis are not mandatory to call a function with zero arguments.
Q18 Answer with (a) to (d) given above. 1

Assertion (A): Number of arguments passed to a function may not match the number of
parameters in the function definition.

Reasoning (R): Function parameters can have default values.


Computer Science/XIISe-l/AGRO-I
SECTIONB

Q19. a) Expand the following albbreviations:


XML
VolP
remotely.
a computer
b) Name ohe protocol that can be used to access
OR
Comparetwisted pair cable andfiber optic cable based on -speed, ccost, electromagnetic
ihterference and distance.
elements of a liist using
program to count the occurrences of a
Q20. Sameer has Butwritten a python
dictionary. the code hassomesyntax and logicalerors. Re-write the code after removing

all such errors and underline your corrections.


L= [1,2,1, 1,2,1,2,3,5,4,1,2,5,4,4,5]
D=

foreach x in L:

if xin D:
D[x]= +1
Else:

D()=1
and n is a numenc
Q21. Write afunction modifyList(Ln) in Python, which accepts a list Lof numbers
value. Function should: 2

Add 5 to all the values divisible by n


Subtract 5 from all values not divisible by n
Display the modified list
Example:
If L= [10,11,13,15,20,2] and n=5 then the function should print [15,6,8,20,25,-3)
OR

Write a user defined function palindrome(s) - which takes a string 's' as arqument and returns
True if it is a palindrome and False if it is not.
Computer ScienceXIISet-IA GRO-I
(A palindrome is a word, phrase, or sequence that reads the same backwards as forwards
-example : madam)
Q22. Predict the output of following python code: 2
S= "BHARAT"
D=)
for i in range(len(S):
if i%2==0:

D[SÜ]=i+1
else:

D[SI] = i-1
for kv in Ditems0: print(k,v,sep="#")
Q23. Consider a List L= [10,20,30,[40,50,60],70,80] 2

Write a single line python statement (using List methods only) to:
i. Insert an element 55 as the second last element of the inner list, so that L becomes

[10,20,30,[(40,50,55,60], 70,80]
ii. Delete the inner list so the Lbecomes [10,20,30,70,80]
Q24. Consider a MySQL table named "Students" with columns - RollNo, Name, Marks. 1x2=2
Write SQL commands to:

() Add a new column named 'Phone' to store the phone number of the students.
(i) Set RollNo as the primary key of the table.
OR

Consider aMysQL table named "Books" with columns - BookID, BookName, Pages, Price,
Rating. The rating column has data type INT.
Write SQL commands to:

) Change the data type of rating column to allow for floating point values (1.0 to 5.0)
(1) Delete the pages column from the database.
Computer Science/XIWSer-I/AGRO-I
Q25. Write the output of the following python code. 2

def runme(x=1,y=2):
X= X+y

y+=1
print(x,'S. y)
return x,y
a,b = runme)
print(a, #,b)
runme(a,b)
Section - (C)

Q26. Write the output of the following python code.


def change(msg):
n= len(msg)
new_msg =

for i in range(0,n):
if not msg[).isalpha):
new_msg = new_msg + @'

else:

if msg[i].isupper):
new_msg = new_msg + msg*2
else:

new_msg=new_msg + msg[]
return new_msg

new_msg = change("15 New Men")


print(new_msg)
Computer Science XTWSet-VAGRO-I
Selld
Q27. Consider the table given below and write the output of SQL queries 0) to () 1*3-3
TABLE: PLAYERS
P ID Name Game Gender DoB Salary
Soae
101 Virat Kohli Cricket M 1990-12-08 12500
102 PV Sindhu Badminton F
103 Rahul Sharma Cricket
1993-01-12 9000
M 1988-01-05 10000
104 Saina Nehwal Badminton F 1990-12-25 8500
105 Pankaj Advani Snooker M 1985-06-16 10000
106
Harmanpreet Cricket 1994-10-10 12500
107 Sardar Singh Hockey M 1982-11-09 9000
108 VAnand Chess M 1982-11-01 12000
Q28. Neha has a very large text file named log_report.txt' which contains more than 50,000 log
entries forlogins on a local ssh server. Following is a truncated view of the file log_report.
txt. 3
2022-10-1422-40:39 Login failed >from 192.168.11.16
2022-10-14:22-20:19Login success >from 192.168.11.220
2022-10-14:10:14:40 Login success >from 192.168.0.66
2022-10-13:11:19:17 Login failed >from 192.168.0.45
2022-10-14:22:4039 Login success > from 192.168.11.156

Neha has asked you to help her count the number of failed login attempts. Wite a function
countFailedAttempts() in python to count the number of lines containing the word failed in
the text file log_report.tot.
OR

Rajat is working on a language statistics project. He has to analyze the writings of afamous
English novelist. He has downloaded a text file named 'russel.txt' containing major wnitings
of the author. He is stuckat the problem of counting the number of wods starting with th'
or Th. Being acomputer science student, help Rajat by writing afunction countWords( )in
python to count the number of words starting with Th' or th' in the text fle 'usseltxt!
Computer Science/XIISet-IWAGR0-1
Q29. Consider the table Employees Given below and write SQL. queries () to (i) based on it. 3

Table: Employees
emp id name dob gender salary
101 26000
Simar 1994-01-15
1995-10-18 M 17000
102 Alok
1996-08-21 M 25000
103 Hasan
35000
104 Kriti 1993-01-12 F
1994-02-20 M NULL
105 Gulab
1993-12-01 16500
106 Jaya

i. To increase the salary of all Female employees by 10%.


salary is NULL.
i. To display the name and gender of employees for whom
January 1995.
ii. To delete the records of all employees born before 01
elements are lists of the format - [temlD,
Q30. Consider a Nested List 'Inventory' in which all the
functions in python to perform
Item Name, Price, Quantity]. Write the following user defined
empty list. 3
the task specified on the stack named "items' which is initially an
records
Push_item(Inventory) - It takes nested list Inventory as argument and pushes
of those items onto stack which have quantity > 100.
Pop_items) -It repeatedly pops the top element of stack and displays it. Appropriate
stack.
message should be displayed when there are no more elements left in the
For example, if
Inventory= [[101, 'Pen', 10, 120],
(102, 'Pencil', 10, 100,
[103, 'Eraser, 5, 90],
[104, Notebook, 20, 52,
(105, 'Marker', 30, 130],
(106, 'Sharpener', 5, 110O)]
Computer ScienceXTI/Ser-VAGRO-I
|91
After execution of Push Items(lnventory), Stack should contain:

mot, Pen, 10, 120), (105, 'Marker, 30, 130), (106, Sharpener, 5, 110|| Top
The output after Pop_Items0 should be
(106, Sharpener, 5, 110j
(105, Marker', 30, 130)
[101, Pen', 10, 120)
Stack Empty
SECTIOND

031. Write theoutput of SQL queries () to (v) based on the relations Employees and Departments
given below: 4

Table :Employees
empid name dob gender salary dept id
101 Simar 1994-01-15 F 26000

102 Alok 1995-10-18 M 17000 2

103 Hasan 1996-08-21 M 25000 1

104 Kriti 1993-01-12 F 35000

105 Gulab 1994-02-20 M 15000

106 Jaya 1993-12-01 16500 4

Table: Departments

dept id dept name dept location


1 HR GF-005

Sales GF-006

3 Analysis SF-204

4 Training FF-102

Computer Science/XII/Set-I/AGRO-I
i.
Display the Average Salary for Male and Female Ernployees.
Display the Employee Name and Department Name for all employees in descending
order of their salary.
after 31 December 1995.
Display the maximum salary of employees born
departments having more
iV. Display the department id and number offemployeesfor all
than 1employee.
csv file 'FOOTBALL.CSV to store player name, matches anid goais scored.
o Vjay has created a
that defines and calls following user defined functions.
wmte d program in python
matches, goals) : Three parameters - name of the player, matches
addPlayer(name, list
scored are passed to the function. The function should create a
played and goals
object and append it to the csv file.
The function should read the csv file and display the name of the
ii. highestAverage( ):
player with the highest average goals (goals/matches).
SECTIONE
Noida. The company campus will have
Q33. Stalwart Solutions Pvt Ltd. is setting up its campus in
company has consulted you
four blocks - Shivaji(S), Tagore (T), Ashoka (A) and Raman (R). The
their questions (a) to (e)
for networking at the campus. Suggest the best possible solutions for
based on the information given below:
1x5=5

No. of Distance
Block Blocks
Computers (m)
Shivaji (S) 75 Shivajito Tagore 25
Tagore (T) 125 Shivaji to Ashoka 150
Ashoka(A) 25 Shivajito Raman 125 R

Raman(R) 20 Tagore to Ashoka 75


Tagore to Raman 90
a) Suggest the most appropriate block to house the FTP server. Justify your answer.
b) Which Hardware/Software can be installed prevent unauthorized access to FTP
server?

Computer Science/XTIISet-I/AGRO-I
cable layout
Suggest the best economical wired transmission medium and drawthe
diagram to connect the four blocks.
connecting the computers
The company doesn't want to use any wired media for
provide wirelessaccess, given
withinthe Raman block.. Which device can be usedto
that allthe machines in this block are wi-fi enabled.
the LAN established. Keeping
trafficin
e) The company wishes to minimize the broadcast
connect the computersinside every
this in mind, which device will you suggest to
block - hub or switch? Why? 2+3a5
files and binary files?
Q34. ) What is the difference between text 'PASSWORDS.DAT The
binary file named
passwords in one
Shweta had stored allher
format:
passwords were stored in following
app_name, username, password]
and
title as a parameter and displays the username
that accepts
Write a function search(app)
password for that particular app.
OR

that does not exist in rb, ab, rb+ and wb+


What happens when we try to open a file
modes?
[ADM_
Consider a file named STUDENTS.DAT, Containing records in following format:t
(i)
NO, NAME, CLASS, SECTION]
class and section as parameters and
Write a function, filterStudents(clas, sec), which takes
new file named'FILTEREDDAT.
copies the records matching with that class and section to a
can act as a
Q35 ) What are the characteristics of a Primary key in RDBMS. Which attribute
school?
primary key for a table storing details of all students ofa
records into the CRICKET
() Heerakh wants to write a program in python to add some
Table of SPORTS Data base. The MySQL server is running on LOCALHOST and the login

credentials are as following:

Computer Science/XII/Se-I/AGRO-1
I 12 1
Username - heerakh
Password -happy
The columns of the CRICKET table are described below:
pid (Player ID) - integer
pname (Player Name) -string
innings (nnings Played) -integer
runs (Runs Scored) - integer
wickets (Wickets taken) - integer
Help her write a program, which will accept the player details from user and inserta new roW
into the table.

OR
) What do you mean by term domain in context of RDBMS? What will be the domain for
an attribute called 'age' of voters of a village?
() hesnav wants to write a program in python to display some records from the CRICKET
Table of SPORTSDatabase. The MySOL serveris running on LOCALHOST and the login
credentials are as following:
Username - keshav
Password - karma

The columns of the CRICKET table are described below:


pid (Player ID) - integer
pname (Player Name) -string
innings (Innings Played) - integer
runs (Runs Scored)- integer
wickets (Wickets taken)-integer

Help him write a program, which willdisplay the name (only name) of all players who
have player 10Q or more innings.

Computer ScienceXIU/Ser-I/AGRO-I

You might also like