0% found this document useful (0 votes)
23 views

G 12 Model 2 Cs Ms-Pcbcs

Uploaded by

msarathikavya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

G 12 Model 2 Cs Ms-Pcbcs

Uploaded by

msarathikavya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

VELAMMAL NEW - GEN EDU NETWORK

MODEL – 2-EXAMINATION

CODE – 083 – COMPUTER SCIENCE ( P C

B C S )

MARKING SCHEME

SECTION – A (21 X 1 = 21 MARKS)


1. True
2. (A) ext#nex
3. (A)12 > 15 and 8 > 12 or not 19 > 4
4. (A) urch#ar
5. (B) ia ea iml
6. (A) True
7. (D) dict_student.update(dict_marks)
8. (B). list.append(element)
9. (C) True and not(False)
10. (A) with open('record.bin','wb') as myfile:
pickle.dump(lst1,myfile)
11. (C) Lists are immutable while strings are mutable.
12. (D) 3 5 5
13. (D) (40,60)
14. (B) r
15. (A) GoodGood
Morning
16. (A) 2
17. (C ) myfile = open('Myfile.txt'); myfile.readline()
18. (A) 24,29
19. b. tells the current position of the file pointer within the file
20. (C) A is True but R is False
21. (C) A is True but R is False

SECTION – B (7 X 2 = 14 MARKS)
A mutable object can be updated whereas an immutable object cannot be updated.
22
Mutable object: [1,2] or {1:1,2:2} (Any one)
Immutable object: (1,2) or ‘123’ (Any one)
(1 mark for correct difference)
(½ x 2 = 1 Mark for example)
I) Logical operators: AND,OR,NOT
23 (II) Relational operators: >, >=
(½ x 4 = 2 Marks for each correct operator)
(i) L1.insert(2,200)
24 (ii) message.endswith('.')
OR
import statistics
print( statistics.mode(studentAge) )
(1 mark for correct answer)
(A), (C) (½ x 2 = 1 Mark)
25
Minimum and maximum possible values of the variable b: 1,3 (½ x 2 =
1 Mark)

26

(½ Mark for correctly identifying and correcting each of the four errors)
4*L
27 33*4
21*S
10*6
(1/2 Mark for each line correct output)
(OR)
7#14#6#7#
(½ mark for the correct digit with a #)
oLYMPIC#gAMES# 202
28
(2 Mark for writing the correct output)

(OR)

1#
(2 Mark for writing the correct output)

SECTION – C (3 X 3 = 9 MARKS)
29

1 mark for correctly opening and closing files


½ mark for correctly reading data
1 mark for correct loop and if statement
½ mark for displaying data
(OR)
1 mark for correctly opening and closing the files
½ mark for correctly reading data
1 mark for correct loop and if statement
½ mark for displaying the output.
def showGrades(S):
30 for K, V in S. items():
if sum(V)/3>=90:
Grade="A"
elif sum(V)/3>=60:
Grade="B"
else:
Grade="C"
print(K,"–",Grade)
S={"AMIT":[92,86,64],"NAGMA":[65,42,43],"DAVID":[92,90,88]}
showGrades(S)
(1 Mark for the loop to process individual students from the dictionary)
(1 Mark for calculating grades)
(1 Mark for displaying grades)
(OR)
Word="TELEVISION"
def Puzzle(W, N):
NW=""
Count=1
for Ch in W:
if Count!=N:
NW+=Ch
Count+=1
else:
NW+="_"
Count=1
return NW
print(Puzzle(Word,3))
(1 Mark for the loop to process individual (or Nth) characters)
(1 Mark for changing/replacing the required characters)
(1 Mark for returning the new word)
(A) (10, 30, 50, 65)
31 ( ½ mark for each correct digit)
(B) 105#6#
(1 mark for each correct line of output)
(OR)
sELCcME&Cc (3 marks for correct output)

SECTION – D (4 X 4 = 16 MARKS)
(A) &&lEARNingpytHON
32 (3 marks for writing the correct output)
(B)
si no (1 mark for correct output)

import csv
33 def add():
fout=open("furdata.csv","a",newline='\n')
wr=csv.writer(fout)
fid=int(input("Enter Furniture Id :: "))
fname=input("Enter Furniture name :: ")
fprice=int(input("Enter price :: "))
FD=[fid,fname,fprice]
wr.writerow(FD)
fout.close()

def search():
fin=open("furdata.csv","r",newline='\n')
data=csv.reader(fin)
found=False
print("The Details are")
for i in data:
if int(i[2])>10000:
found=True
print(i[0],i[1],i[2])
if found==False:
print("Record not found")
fin.close()
add()
print("Now displaying")
search()

½ mark for importing csv module


1 ½ marks each for correct definition of add() and search()
1 ½ checking the condition and display
½ mark for function call statements
(A)
34 dict_values([['Rahul', 95], ['Siya', 90], ['Rajan', 80]])
(1 mark for correct output)
(B)
def search_replace(L,SN):
Found=False
for i in range(len(L)):
if L[i]==SN:
L[i]=0
Found=True
if Found==False:
print('Number not found')

(½ Mark for writing the function header correctly)


(½ Mark for passing the correct parameters)
(½ Mark for writing the correct loop)
(½ Mark for comparing the number from elements of L)
(½ Mark for assigning the compared element as 0)
(½ Mark for displaying appropriate message when no matching element found)
(I)
35 def show():
import csv
f=open("happiness.csv",'r')
records=csv.reader(f)
for i in records:
if int(i[1])>5000000:
print(i)
f.close()

(½ mark for opening in the file in right mode)


(½ mark for correctly creating the reader object)
(½ mark for correctly checking the condition)
(½ mark for correctly displaying the records)

(II)
def Count_records():
import csv
f=open("happiness.csv",'r')
records=csv.reader(f)
count=0
for i in records:
count+=1
print(count)
f.close()

(½ mark for opening in the file in right mode)


(½ mark for correctly creating the reader object)
(½ mark for correct use of counter)
(½ mark for correctly displaying the counter)

SECTION – E (2 X 5 = 10 MARKS)
(A)
36 Advantage of a csv file:
* It is human readable – can be opened in Excel and Notepad
applications
* It is just like text file

(B)
import pickle
def WRITEREC():
f = open("PLANTS.dat","wb")
data_log = []
while True:
ID = int(input("Enter ID:"))
NAME = input("Enter Name:")
PRICE = float(input("Enter Price:"))
data_log.append([ID,NAME,PRICE])
Choice=input("Do you want to add more? (Yes/No) : ")
if Choice[0].lower()=='n':
break
pickle.dump(data_log,f)
f.close()

def SHOWHIGH():
f = open("PLANTS.dat","rb")
try:
while True:
data= pickle.load(f)
for record in data:
if record[2]>500:
print("ID:",record[0])
print("Name:",record[1])
print("Price:",record[2])
print()
except:
f.close()

(½ Mark for correctly opening the PLANTS.dat file to write/append)


(½ Mark for correctly inputting data from the user)
(1 Mark for correctly writing the input data as a record into the file)
(1 Mark for correctly loading the the file)
(½ Mark for correctly checking each record price > 500)
(½ Mark for displaying the validated record)

(A)
37 Difference between binary file and csv file: (Any one difference may be given)
Binary file:
Extension is .dat
Not human readable
Stores data in the form of 0s and 1s
CSV file
Extension is .csv
Human readable
Stores data like a text file

(B)
import pickle
def countrec():
f = open("PATIENTS.dat","rb")
N=0
try:
while True:
data= pickle.load(f)
for record in data:
if record[2]=='COVID-19':
print("PID:",record[0])
print("NAME:",record[1])
print("DISEASE:",record[2])
N += 1
except:
f.close()
print('Total number of Covid-19 Patients = ', N)
(½ mark for function definition)
(½ mark for opening the file in correct mode)
(1 mark for reading the binary file)
(1 mark for the traversal loop)
(½ mark for checking the COVID-19 condition)
(½ mark for displaying the matched records)
(½ mark for displaying the final value of the Counter Identifier)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy