ANSWERS- GRADE 12 - CS PT2
SECTION A (1 Mark each)
1. True
2. A)Packet switching
3. C)seek()
4. B)communication channel
5. C)infi.readline()
6. D)b
7. F = open(‘Notes.txt’) ; print(F.read(10))
8. Server
9. Fibre optic
10. A network of lab computers of a testing lab
11. (a) both a and r are true and r is the correct explanation of assertion
SECTION B (2 Marks each)
12)import csv
f = open("book.csv", "a")
cr = csv.writer(f)
srec = ["R1", "Tennis", "Outdoor", 4]
cr.writerow(srec)
f.close()
13)Communication channels are transmission mediums used to transfer data from one point to
another. Types include:
Twisted pair cable
Coaxial cable
Fibre optic cable
Wireless (radio, microwave, infrared)
14) tell() and seek() proper answer accepted
15)Text file mode: Used for readable characters (e.g., ‘r’, ‘w’)
Binary file mode: Used for non-text files like images (e.g., ‘rb’, ‘wb’)
SECTION C (3 Marks each)
16)import pickle
f = open("College.dat", "rb")
try:
while True:
rec = pickle.load(f)
if rec[3] > 30:
print(rec)
except EOFError:
f.close()
17) star topology
LAN
Advantage: Easy to implement and cost-effective
18)import csv
# (I)
def display_large_population():
with open("Happiness.csv", "r") as f:
cr = csv.reader(f)
for row in cr:
if int(row[1]) > 5000000:
print(row)
# (II)
def count_records():
count = 0
with open("Happiness.csv", "r") as f:
cr = csv.reader(f)
for row in cr:
count += 1
print("Number of records:", count)
SECTION D (4 Marks each)
19)
(i) csv.writer() creates a writer object to write data to CSV files.
def copy():
with open("dept.dat", "r") as f, open("com.dat", "w") as fout:
for line in f:
data = line.strip().split(',')
if data[1].lower() == "computer":
fout.write(line)
20)
(a) Jamuna
(b) Proper layout accepted
( c)
(i) Switch: In each block for managing internal network traffic
(ii) Repeater: For signal boosting if distance >100m
D) Optical fiber
21)
(i) writerows() writes multiple records to a CSV file.
(ii)
import csv
def addToy():
count = 0
with open("Toys.csv", "a", newline="") as f:
wr = csv.writer(f)
while True:
tid = input("Toy ID: ")
name = input("Toy name: ")
cat = input("Category: ")
cost = int(input("Cost: "))
if cat.lower() == "boys":
wr.writerow([tid, name, cat, cost])
count += 1
more = input("Add more? (y/n): ")
if more.lower() != 'y':
break
print("Toys added:", count)
def showToys():
with open("Toys.csv", "r") as f:
rd = csv.reader(f)
for row in rd:
if int(row[3]) > 1000:
print(row)