answer key- csc
answer key- csc
SECTION-A(1*21=21 MARKS)
QN Answers
1. Ans. False. 1
2. Ans. (a) 1
3. Ans: (b) True, as firstly “not” performed then “And” performed and at last 1
“Or” performed.
True or not True and False
True or False and False
True or False
True
4. Ans. (d) dict_student.update(dict_marks), as we use update method for 1
dictionary merging with syntax dict1.update(dict2)
5. Ans. (b) tuple, as Elements enclosed in parentheses( ) represents by 1
tuple.
6. Ans: (d) (40,60), as this expression will slice the given tuple starting with 1
index position 3 and selecting every second element till index number 7.
7. Ans. (c) None, as it is empty value. 1
8. Ans. (c) 512, as 2**3**2= 2**9=512 is the answer. 1
9. Ans. (b) Statement 4, as string’s individual element can’t assigned new 1
value so S[0]= '@' # Statement 4 give error.
10. Ans. (c) F=open(‘Notes.txt’) 1
print(F.read(10))
As read method in python is used to read at most n bytes from the file
associated with the given file descriptor. If the end of the file has been
reached while reading bytes from the given file descriptor, os.read( )
method will return an empty bytes object for all bytes left to be read.
11. Ans. (a) Pickling, as pickling is used for object serialization in handling 1
of Binary Files.
12. Ans. (d) n is local and x is global variable 1
As n is defined within function body and x is defined outside the function
body.
13. Alter- Add command is used to add a new column in table in SQL. 1
14. Ans. (b) DISTNICT, as DISTNICT Keyword is used to obtain Non- 1
duplicated values in a SELECT query.
15. Ans. (c) sum( ), as it’s used for summation of numeric values in a 1
column.
16. Ans. (a) Mycur.fetch(), as it’s not a valid method for fetching. 1
17. Ans. (c) Both Modualtion & Demodulation, as MODEM does both 1
tasks.
18. Ans. (a) 1
1|Page
SECTION-B (2*7=14 MARKS)
22 Mutable Objects: ½
. These objects can be modified after creation (e.g., adding, removing, or *4=
updating elements). 2
Changes are done in place, without creating a new object.
Immutable Objects:
These objects cannot be modified after creation.
Any modification creates a new object instead of altering the original
Mutable Object: {1, 2, 3} or {'a': 1, 'b': 2}
Immutable Object: "abc" or (10, 20)
23 x = 10 1+1
. y = 20 =2
# Using the logical operator and
if x > 5 and y > 15:
print("Both conditions are True") # Output: Both conditions are True
z=5
# Using the assignment operator +=
z += 3 # Equivalent to z = z + 3
print(z) # Output: 8
24 (i)A) str="PYTHON@LANGUAGE" 2
. print(str[2: : ])
OR
B) d=dict( )
(ii)A) s=”LANGUAGE"
l=list(s)
OR
B) t=tuple( )
25 Ans : ( c ) Minimum and maximum possible values of variable x 2
. 2 and 7.
26 COUNT(*) returns the count of all rows in the table, 2
. whereas COUNT (COLUMN_NAME) is used with Column_Name
passed as argument and counts the number of non-NULL values in
the particular column that is given as argument.
Example:
A MySQL table, sales have 10 rows with many columns, one column
name is DISCOUNT.
This DISCOUNT column has 6 valid values and 4 empty/ null
values. When we run the Following queries on sales table.
SELECT COUNT(*)
FROM sales;
COUNT(*)
10
SELECT
COUNT(DISCOUNT)
FROM sales;
COUNT( DISCOUNT )
6
As in table, there are 10 rows so count(*) gives 10 and discount
column is having 6 valid values with 4 NULLvalues so it gives 6.
2|Page
27 1+1=
2
.
28 A) Cost-Effective: Bus topology is inexpensive to set up because it 2
. requires less cable compared to other topologies.
Disadvantage of Bus Topology:
Single Point of Failure: If the main cable (backbone) fails, the entire
network becomes inoperable, making it less reliable for larger setups.
B) HTTP stands for Hyper Text Transfer Protocol
1. Transferring Data.
2. Request-Response Communication:
3. Accessibility:
4. Stateless Communication:
SECTION-C (3*3= 9 Marks)
29 A) 3
. def countlines_et():
f=open("report.txt",'r')
lines=f.readlines()
linee=0
linet=0
for i in lines:
if i[0]=='E':
linee+=1
elif i[0]=='T':
linet+=1
print("No.of Lines with E:",linee)
print("No.of Lines with T:",linet)
countlines_et()
OR
B)
def show_todo():
f=open("abc.txt",'r')
lines=f.readlines()
for i in lines:
if "TO" in i or "DO" in i:
print(i)
show_todo()
30 A) (I) 3
. def push_customer(CustomerStack,new_customer):
CustomerStack.append(new_ customer)
(II)
def pop_customer(CustomerStack):
if not CustomerStack:
print("Underflow")
3|Page
else:
return(CustomerStack.pop())
(III)
def peep_customer(CustomerStack):
if not CustomerStack:
print("None")
else:
print(CustomerStack[-1])
31 31) b.
1 #2 #3 #
1 #2 #3 #
1#
4|Page
OR
B)
def push(EventDetails):
BigEvents=[]
count=0
for i in EventDetails:
if EventDetails[i]>200:
BigEvents.append(i)
count+=1
print(“The count of elements in the stack is”,count)
def pop(EventDetails):
if len(EventDetails)==0:
return "Dictionary is empty"
else:
return EventDetails.pop()
push(EventDetails)
print(pop(EventDetails))
(½ mark should be deducted for all incorrect syntax. Full marks to
beawarded for any other logic that produces the correct result.)
31 a) 15@ 1*3
7@ =3
9@
(OR)
b) 1#2#3#
1#2#3#
1#
SECTION-D (4*4= 16 Marks)
32 A) 1+3
. (i) SELECT EMP_NAME, BASIC+DA+HRA+NPS AS “GROSS =4
SALARY” FROM EMPLOYEE;
(ii) UPDATE EMPLOYEE SET DA=DA+0.03*BASIC;
(iii) ALTER TABLE EMPLOYEE DROP COLUMN EMP_DESIG;
(iv) SELECT emp_name FROM Employee
WHERE (basic + da + hra) > 100000;
OR
B)
(i) SELECT COUNT(*) FROM EMPLOYEE;
(ii) SELECT * FROM EMPLOYEE ORDER BY basic desc;
(iii) SELECT SUM(hra) FROM EMPLOYEE;
(iv) SELECT COUNT(*) AS employee_count
FROM Employee
WHERE basic > 50000;
5|Page
33 (I) 2+2
. import csv =4
def show():
f=open("HealthSurvey.csv",'r')
k=csv.reader(f)
next(k, None) #To skip the Header row
for i in k:
if float(i[3])>5:
print(i)
f.close()
ii)
import csv
def Count_records():
f=open("HealthSurvey.csv ",'r')
k=csv.reader(f)
next(k, None) #To skip the Header row
count=0
for i in k:
count+=1
print(count)
f.close()
show()
Count_records( )
34 i) SELECT SUM (PERIODS), SUBJECT FROM SCHOOL GROUP BY 1*4
. SUBJECT ; =4
6|Page
print("Display Employee whose age is more than 55 years:")
mycursor.execute("select * from Emp where age>55”)
EmpRec= mycursor.fetchall()
for rec in EmpRec:
print(rec)
SECTION-E (2*5= 10 Marks)
36 Binary Files- It is usually much smaller than a text file.For image, video 1+2
and audio data this type of file is important and it’s extension is .det or +2=
.dat. Compiler does not need to convert these files as these files are in 5
the machine readable form hence these files consumes less time to
execute and process faster.
(a) import pickle
def AddOrder():
f=open("Stock.dat",'ab')
OrderId=input("Enter Order Id")
MedicineName=input("Enter Medicine Name")
Qty=int(input("Enter Quantity:"))
Price=int(input("Enter Price:"))
data=[OrderId,MedicineName,Qty,Price]
pickle.dump(data,f)
f.close()
AddOrder()
(b)
def DisplayPrice():
f=open("Stock.dat",'rb')
try:
while True:
data=pickle.load(f)
if data[3]>500:
print(data[0],data[1],data[2],data[3],sep="\t")
except:
f.close()
DisplayPrice()
37 i) ADM Block 1*5
Justification- It has maximum number of computers. Reduce traffic. =5
ii) wired medium is UTP/STP cables
DEVELOPMENT HUMANRESOURCE
LOGISTICS ADM
iii) (a) Switches in all the blocks since the computers need to be
connected to the network.
(b) Repeaters between ADM and HUMANRESOURCE block & ADM
and Logistics block. The reason being the distance is morethan 100m.
iv) Modem should be placed in the Server building
v) (c)OFC-Optical Fiber cable, this connection is high-speed wired
communication medium.
OR LAN will be set up among computers connected in Campus.
7|Page