MS - Hy Cs Xii2023
MS - Hy Cs Xii2023
An b) pop()
s
5 Which of the following python function header declaration is wrong? 1
a) def myfunction(x, y, z):
b) def myfunction(x, y=10, z=20):
c) def myfunction():
d) def myfunction(x=10, y, z=20):
An d) def myfunction(x=10, y, z=20):
s
6 When a python function returns more than one value in a single return statement, which of the 1
following collection objects gets returned?
a) List b) Tuple c) Dictionary d) String
An b) Tuple
s
7 Which type of exception will be raised for the operation print('A'+10) 1
a) ValueError
b) TypeError
c) KeyError
d) NameError
An b) TypeError
s
8 Which of the following modes will allow the file to be opened for only writing? 1
a) 'a+'
b) 'r+'
c) Both option a) and b)
d) Neither option a) nor option b)
An d) Neither option a) nor option b)
s
9 Consider a file 'string.txt' has some characters written into it. Now the file is opened in 'rb' mode using 1
the file object myfile. What will be the output of the following python operation?
myfile.read(4)
myfile.seek(5,1)
myfile.read(2)
myfile.seek(-4,1)
print(myfile.tell())
a) 8 b) 7 c) 6 d) Error
An b) 7
s
10 Which of the following network devices is used to connect between two dissimilar protocols? 1
a) Switch b) Router c) Modem d) Gateway
An d) Gateway
s
11 Which network protocol provides a command line interface for communication with a remote device or 1
server?
a) Telnet b) HTTP c) PPP d) SMTP
An a) Telnet
s
12 Which of the following switching techniques sends small pieces of data across a network? 1
a) Circuit switching
b) Message switching
c) Packet switching
d) All the above.
An c) Packet Switching
s
13 Which of the following is false for XML? 1
a) XML is a case sensitive language.
b) XML is used to describe data for a webpage.
c) XML has fixed set of tags.
d) XML can be used as a meta language.
An c) XML has fixed set of Tags.
s
14 Which of the following protocols is used to receive emails? 1
a) POP3 b) SMTP c) FTP d) TCP
An a) POP3
s
Questions 15 to 18 are ASSERTION AND REASONING based questions. Mark the correct choice
as:
i) Both A and R are true and R is the correct explanation for A
ii) Both A and R are true and R is not the correct explanation for A
iii) A is True but R is False
iv) A is false but R is True
24 Rewrite the following program after removing the errors. Also underline the corrections made. 2
n = int(input())
if n % 10 = 0:
n = n + 10
elif n >= 20:
n =- 5
else
n = 40
print("n=" n)
An n = int(input())
s if n % 10 == 0:
n = n + 10
elif n >= 20:
n -= 5
else:
n = 40
print("n=", n)
25 Write one advantage and one disadvantage of bus topology. 2
An Advantage: Less cable requirement
s Disadvantage: Network stops or gets segmented if the backbone cable breaks.
Or any other advantage and disadvantage.
26 Expand the following abbreviations: 2
a) SMTP
b) ARPANET
An a) Simple Mail Transfer Protocol
s b) Advanced Research Project Agency Network
SECTION – C
27 Fill in the blanks for the following questions: 3
a) ___________ topology is highly dependent on the central node.
b) The unit of measurement of data transfer rate is ____________.
c) The relative address of a document or a resource on a webserver is called ___________.
An a) Star b) baud or bits per sec c) URL
s
28 Predict the output of the following python program: 3
def changeme(a,b=10):
global c
a += b
b += c
c=a+b
print(a, b, c)
return b//2
a,b,c= 5,20,15
b = changeme(a,c)
print(a,b,c)
An 20 30 50
s 5 15 50
(1/2 marks for each correct option)
29 What will be the output of the following python program: 3
data = [10, 20, 30, [40,50,60],70]
x = data.pop(3)
print(x)
data[2:2]=[40,50]
print(data[4])
print(len(data))
An [40, 50, 60]
s 30
6
[OR]
What will be the output of the following python program:
name = "HOME ALONE WITH MOM"
data = name.partition('ALONE')
print(data[0].lower())
print(data[2].title())
print(data[1][::-2])
An home
s With Mom
EOA
30 A pre-written text file data.txt has some strings stored in it. Write a python function display() that reads 3
the contents of the file and displays all the words that start with the substring 'th' or 'Th'.
Eg. If the file has the following data:
“There was a man who throughout his life
thanked others for their little help”
The output should be:
There
throughout
thanked
[OR]
A pre-written text file info.txt has some strings written in it. Write a python function countme() that
reads the contents of the file and returns the count of all the words which are 'that'.
An def display():
s f = open('data.txt', 'r')
s = f.read()
l = s.split()
for x in l:
if x.startswith('th') or x.startswith('Th'):
print(x)
f.close()
[OR]
def countme():
count=0
f = open(info.txt', 'r')
s = f.read()
l = s.split()
for x in l:
if x == 'that':
count+=1
f.close()
return count
31 A pre-written text file info.txt has some lines written in it. Write a function display() that prints all the 3
lines that has the word 'India' in them.
[OR]
A pre-written text file data.txt has some lines written in it. Write a function display() that prints all the
lines that have exactly 10 words in them.
An def display():
s f = open('info.txt', 'r')
for line in f:
if 'India' in line:
print(line)
f.close()
[OR]
def display():
f = open('data.txt', 'r')
for line in f:
l = line.split()
if len(l)==10:
print(line)
f.close()
32 a) Mention two differences between a hub and a switch. (2) 3
b) Give one example of a popular web browser. (1)
Write a python function popstack(stack) that pops out the last added element from the stack each time
the function is called and also prints a 'Stack Empty' message if all the elements have popped out.
Also write the call statements for both the functions.
An def push(stack):
s data = {'ROY':100, 'ARORA':200, 'MADAM':250, 'SAHA':300, 'LEVEL':400}
for x in data:
if x==x[::-1]:
stack.append(data[x])
def popstack(stack):
if len(stack)==0:
return 'Stack Empty'
else:
return stack.pop()
stack=[]
push(stack)
print(popstack(stack))
4 marks for the correct code. Marks should be deducted based on syntax, indentation, and logical
errors.
[OR]
def push(stack):
data = ['ROYAL', 'ARMSTRONG', 'MADAM', 'PYTHON', 'ANACONDA']
for x in data:
if len(x)>5:
stack.append(x)
def popstack(stack):
if len(stack)==0:
return 'Stack Empty'
else:
return stack.pop()
stack=[]
push(stack)
print(popstack(stack))
SECTION – E
35 Rohit wants to create a python application that writes a set of records in a csv file info.csv. He is having 5
some issues and has left a few blank lines. On behalf of Rohit, you are directed to write the missing
codes.
_____________ # Statement 1
f = open('info.csv', 'w', newline='')
csvwriter = __________________ # Statement 2
head = ['Id', 'Book', 'Quantity', 'Price']
data = [[101, 'Stardust', 100, 50], [102, 'Athabasca', 200, 300], [103, 'Troy', 150, 180]]
___________________ # Statement 3
___________________ # Statement 4
___________________ # Statement 5
a) Statement 1 : Write a statement that enables python to work with csv files.
b) Statement 2 : Write a statement to initialize the csvwriter object.
c) Statement 3 : Write a statement to write the head object to the file.
d) Statement 4 : Write a statement to write the data object to the file.
e) Statement 5 : Write a statement to end the program be releasing the file handle f.
a) Statement 1 : import csv
b) Statement 2 : csv.writer(f)
c) Statement 3 : csvwriter.writerow(head)
d) Statement 4 : csvwriter.writerows(data)
e) Statement 5 : f.close()
36 Tribor infotech has their new campus in Bangalore. They have four buildings on their campus that need 5
to be connected through a network. The details of the number of computers in each building and
distance between the buildings are as below.
Accoun
HR
ts
Tech Admin
Account
HR
s
Tech Admin
c) Switches in all the buildings and Repeater between Admin and Accounts building
d) OFC
e) PPP