Electrical

CBSE Sample Papers for Class 12 Computer Science Set 7 with Solutions

Students must start practicing the questions from CBSE Sample Papers for Class 12 Computer Science with Solutions Set 7 are designed as per the revised syllabus.

CBSE Sample Papers for Class 12 Computer Science Set 7 with Solutions

Time: 3 hrs Max.
Marks: 70

Instructions

1. Please check this question paper contains 35 questions.
2. The paper is divided into 5 Sections A, B, C, D and E.
3. Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
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 carries 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. All programming questions are to be answered using Python Language only.

Section – A

Question 1.
State True or False [1]“A tuple is a immutable data type.”
Answer:
True

Question 2.
Which of the following Python functions do not require importing of a module? [1](a) type()
(b) input()
(c) sqrt()
(d) Both (a) and (b)
Answer:
(d) Both (a) and (b)

Question 3.
The alternate to math.pow() function is operator. [1](a) **
(b) *
(c) +=
(d) /
Answer:
(a) **

CBSE Sample Papers for Class 12 Computer Science Set 7 with Solutions

Question 4.
To print all elements of tuple in reverse order using [1](a) [: – 1](b) [: : – 1](c) [1 : : ](d) [: : 1]Answer:
(b) [: : -1]

Question 5.
Given : s=”[email protected]”. What will be the output of print(s[2: :2])? [1](a) ‘ypcalcm’
(b) ‘ypcgalcm’
(c) ‘ypcglcm’
(d) ‘pcgalm’
Answer:
(b) ‘ypcgalcm’

Question 6.
Which of the following modes open a text file, such that the new data is written in it keeping the existing contents ? [1](a) r+
(b) rw+
(c) w+
(d) a
Answer:
(d) a

Question 7.
Which of the following functions does not require any arguments? [1](a) random()
(b) randint()
(c) randrange()
(d) choice()
Answer:
(a) random()

Question 8.
Which statement of SQL provides statements for manipulating the database objects? [1](a) DDL
(b) DML
(c) DCL
(d) TCL
Answer:
(b) DML

Question 9.
Write the output of given code [1]

s1 = ‘Hello’
s2 = ‘World’
s = s1 + s2
print(s)

(a) Hello World
(b) HelloWorld
(c) ‘Hellow’ ‘World’
(d) Error
Answer:
(b) HelloWorld

Question 10.
An alternate key can be [1](a) only 1 in a table.
(b) a table can have maximum 2 alternate keys.
(c) a table can have at most 3 alternate keys.
(d) multiple in a relation.
Answer:
(d) multiple in a relation

Question 11.
Fill in the blank :
The ………. clause with GROUP BY, can filter groups from the query output. [1](a) WHERE
(b) FILTER
(c) HAVING
(d) CHECK
Answer:
(c) HAVING

Question 12.
Which attribute is used to return access mode with that file was opened? [1](a) file.mode
(b) mode.file
(c) filemode
(d) None of these
Answer:
(a) file.mode

Question 13.
State whether the following statement is True or False:
WAN refers to a small, single site network. [1]Answer:
False

Question 14.
Given a list L=[6,12,9,40,2,1]. Which of the following statements will arrange the list in reverse order? [1](a) L.arrange()
(b) L.sort()
(c) L.sort(reverse=True)
(d) L.sort(reverse=False)
Answer:
(c) L.sort(reverse=True)

CBSE Sample Papers for Class 12 Computer Science Set 7 with Solutions

Question 15.
Fill in the blank
………… is a unique name that identifies a particular website and represents the name of the server. [1]Answer:
Domain Name

Question 16.
Identify among the following which is mainly used to host website. [1](a) Mail server
(b) Web server
(c) Database server
(d) None of these
Answer:
(b) Web server

Directions In the question numbers 17 and 18, a statement of Assertion (A) is followed by a statement of Reason (R). Choose the correct option.

Question 17.
Assertion (A) A function with 3 formal parameters must be called with 3 actual parameters. [1]Reason (R) Since, all the formal parameters are used to produce the output from the function, the function expects the same number of parameters from the function call.
(a) Both A and R are true and R is the correct explanation of A.
(b) Both A and R are true but R is not the correct explanation of A.
(c) A is true but R is false.
(d) A is false but R is true.
Answer:
(a) Both A and R are true and R is the correct explanation of A.

Question 18.
Assertion (A) A binary file uses the dump() function to write data into it. [1]Reason (R) The load() function reads data from a binary file.
(a) Both A and R are true and R is the correct explanation of A.
(b) Both A and R are true but R is not the correct explanation of A.
(c) A is True but R is false.
(d) A is false but R is true.
Answer:
(b) Both A and R are true but R is not the correct explanation of A.

Section – B

Question 19.
(a) Expand the following terms [1 + 1 = 2]HTTPS, HTML
(b) Which cable networks are used for LAN connections?
Answer:
(a) HTTPS HyperText Transfer Protocol Secure
HTML HyperText Markup Language
(b) Twisted pair and fibre optic cables are used for LAN connections.

Or

(a) Write down the name of communication channel used for telephone line and TV.
(b) Why is a switch called an intelligent hub?
Answer:
(a) Communication channel for telephone line is twisted pair cable and for TV is co-axial cable.
(b) A switch is also known as intelligent hub because a hub forwards each incoming packet (data) to all the hub ports. Whereas, a switch forwards each incoming packet to the specified recipient.

Question 20.
What will be the output of following code ? [2]

L=[10, 30, 50, 60]
L.append(70)
L.insert(2,80)
L.sort()
print(L)

Answer:
[10, 30, 50, 60, 70, 80]

Question 21.
Find outputs of following code [2]

L=[118,16,[20,30,50],120]
L1=[12,16,17]
L.extend(L1)
print(L[2][2])
print(L)

Or

Find the output of following code

t1=(9, 6, 1, 12)
t2= (10, 11, 12)
print(t1+t2)
print(t1*2)
print(t2-t1)

Answer:
50
[118, 16, [20, 30, 50], 120, 12, 16, 17]

Or

(9, 6, 1, 12, 10, 11, 12)
(9, 6, 1, 12, 9, 6, 1, 12)
Error

Question 22.
What do you understand by primary key? Give a suitable example of primary key from a table
containing some meaningful data. [2]

Or

Define UPDATE command of SQL with its basic syntax and also give one of its example.
Answer:
A primary key is a set of one or more attributes that can uniquely identify tuples within the relation.
e.g.
TABLE: ITEM
CBSE Sample Papers for Class 12 Computer Applications Set 7 with Solutions 7
The attribute ItemNo is a primary key in ITEM table as it contains unique value for each tuple in a relation.

Or

An UPDATE command is used to directly change or modify the value stored in one or more fields in a specified record.

Syntax

UPDATE table_name
SET column1 = value1,
column2 = value2,....
WHERE ;

e.g. Consider the table PERSONS to update the address as Nissestien 67.
UPDATE PERSONS SET Address = ‘Nissestien 67’;

CBSE Sample Papers for Class 12 Computer Science Set 7 with Solutions

Question 23.
Rewrite the following code into for loop [2]

i = 3
while (i < 5): 
if (i == 4): 
print ("Welcome”) 
else: 
print ("No entry”) 
i = i + 1 
print (“value of i”, i)

Answer:

for i in range (3, 5):
if (i = = 4):
print (“Welcome”)
else:
print (“No entry”)
print ("value of i”, i)

Question 24.
What will be the output of the following code, when executed? [2]

d={'Name':'Ram','Subjects':['Eng','Physics','CS'],'Marks':[67,78,90])
print(d['Subjects'])
print(d['Subjects'][2])

Or

What will be the output of the following code, when executed?

tupnames=("India","Australia",("UK","Nepal"),"Bangladesh")
print(tupnames[5:]) 
print(tupnames[2][1])

Answer:
[‘Eng’, ‘Physics’, ‘CS’]‘CS’

Or

( )
‘Nepal ‘

Question 25.
Write an algorithm to find out whether the given number is divisible by 3 or not. [2]Answer:
The algorithm is
Step 1 Start
Step 2 Input “ Enter a Number” N
Step 3 Let R = N % 3
Step 4 If R = 0, then “N is divisible by 3”
Step 5 If R!= 0, then “N is not divisible by 3”
Step 6 Stop

Section – C

Question 26.
Consider the following table STORE and answer the questions [1 × 3 = 3]TABLE: STORE
CBSE Sample Papers for Class 12 Computer Applications Set 7 with Solutions 3
Write SQL commands for the following statements:
(i) To display details of all the items in the STORE table in ascending order of LastBuy.
(ii) To display ItemNo and Item name of those items from STORE table, whose Rate is more than ₹ 15.
(iii) To display the details of those items whose Supplier code (Scode) is 22 or Quantity in Store (Qty) is more than 110 from the table STORE.
Answer:
(i) SELECT * FROM STORE ORDER BY LastBuy;
(ii) SELECT ItemNo, Item FROM STORE WHERE Rate>15;
(iii) SELECT * FROM STORE WHERE Scode = 22 OR Qty>110;

Question 27.
Write a program to accept a filename and a position. Using the inputs, call a function SearchFile(Fname, pos) to read the contents of the file from the position to the end. Now, display all those words that start with “U” or “u”. [3]

Or

Write a program to search an Employee record according to Id from the “emp.txt” file. The “emp.txt” file contains Id, Name and Salary fields. Assume that first field of the employee records (between Id and Name) is separated with a comma(,).
Answer:

def SearchFile(Fname, pos);
f=open(Fname,”r”)
f.seek(pos)
data=f.read( )
datawords=data.split(‘ ’)
for w in datawords :
if w[0] in "uU” :
print(w)

Or

import os
f1=“emp.txt”
if os.path.isfile(f1):
fob=open(f1)
eid=int(input(“Enter employee id:”))
flag=False
for emp in fob:
strlen=len(emp)
i=0
strid=“ ”
while True :
if(emp[i]==“ , ”):
break
if(emp[i]>=‘0' and emp[i]<=‘9’):
strid=strid+emp[i]
i =i + 1
nid=int(strid)
if(eid==nid) :
print(“Employee found: ”,emp)
flag=True
break
fob.close( )
if(flag== False):
print("Record does not found”)
else:
print("File does not exist”)

CBSE Sample Papers for Class 12 Computer Science Set 7 with Solutions

Question 28.
Consider the following tables GARMENT and FABRIC. Write SQL commands for the statements (i) to (iii). [1 × 3 = 3] TABLE: GARMENT
CBSE Sample Papers for Class 12 Computer Applications Set 7 with Solutions 4
TABLE:FABRIC

FCODE TYPE
F04 POLYSTER
F02 COTTON
F03 SILK
F01 TERELENE

(i) To display GCODE and DESCRIPTION of each GARMENT in descending order of GCODE.
(ii) To display the details of all the GARMENTS, which have READYDATE in between 08-DEC-07 and 16- JUN-08 (inclusive of both the dates).
(iii) To display the average PRICE of all the GARMENTS. Which are made up of FABRIC with FCODE as F03.
Answer:
(i) SELECT GCODE, DESCRIPTION FROM GARMENT ORDER BY GCODE DESC;
(ii) SELECT*FROM GARMENT WHERE READYDATE BETWEEN ‘08-DEC-07’ AND ‘16-JUN-08’;
(iii) SELECT AVG(PRICE) FROM GARMENT WHERE FCODE = ‘F03’;

Question 29.
Write a user defined function change(L) to accept a list of numbers and replace the number in the list with its factorial. [3]Example : Input: [3,4,5,6,7]Output: [6, 24, 120, 720, 5040]Answer:

L = []
n = int (input(“Enter number of elements”))
for i in range (1, n + 1):
b = int (input (“Enter element:”))
L.append (b)
j=0
for a in L:
f=1
for i in ranged, (a+1)):
f=f*i
L[j]=f
j+=1
print(L)

Question 30.
Suppose STACK is allocated 6 memory locations and initially STACK is empty (Top = 0). [3]Given the output of the program segment:

AAA = 4
BBB = 6
Push (STACK, AAA)
Push (STACK, 4)
Push (STACK, BBB +2)
Push (STACK, AAA + BBB)
Push (STACK, 10)
while (Top>0) :
Element = STACK. Pop ( )
print(Element)

Answer:
Output
10
10
8
4
4

Section – D

Question 31.
Consider the following table Student [1 × 4 = 4]Table: Student
CBSE Sample Papers for Class 12 Computer Applications Set 7 with Solutions 5

Write statements to
(a) Display the average Marks.
(b) Display the different Classes.
(c) Change the data type of Marks column so that it can take fractional values upto 2 decimals.
(d) Increase width of Name column to varchar(50).
Answer:
(a) SELECT AVG(Marks) FROM Student;
(b) SELECT DISTINCT Class FROM Student;
(c) ALTER TABLE Student MODIFY Marks float(8,2);
(d) ALTER TABLE Student MODIFY Name varchar(50);

Question 32.
Write a program using functions : [4]addTransaction() To append bank transactions of following structure to “bank.csv”
TranID TranDate Amount Type
getTran() To display those transactions whose type is “Deposit”.
Answer:

import csv
def addTransaction():
f1 = open("bank.csv", 'w', newline = "\n")
w1 = csv.writer(f1, delimiter = "\t")
w1.writerow(['TranID', 'TranDate', 'Amount’, Type’])
while True:
op = int(input("Enter 1 to add and 0 to exit"))
if(op == 1):
TranID = int(input("Enter transaction ID: "))
Trandate = input("Enter date: ”)
Amount = int(input("Enter amount: "))
Type=input("Enter transaction type : "))
w1.writerow([TranID, Trandate, Amount, Type])
elif op == 0:
break
f1.close()
def getTran():
f = open("bank.csv”, 'r')
r = csv.reader(f, delimiter=",")
for row in r :
if “Deposit” in row[3] :
print(row)
f.close( )
addTransaction( )
getTran( )

Section – E

Question 33.
Granuda consultants are setting up a secured network for their office campus at Faridabad for their day-to-day office and web based activities. They are planning to have connectivity between 3 buildings and the head office situated in Kolkata. [1 × 5 = 5]Answer the questions (a) to (e) after going through the building positions in the campus and other details, which are given below:
Distance between various buildings

Building RAVI to Building JAMUNA 120 m
Building RAVI to Building GANGA 50 m
Building GANGA to Building JAMUNA 65 m
Faridabad Campus to Head Office 1460 km

Number of computers

Building RAVI 25
Building JAMUNA 150
Building GANGA 51
Head Office 10

(a) Suggest the most suitable place (i.e. block) to house the server of this organisation. Also, give a reason to justify your suggested location.
(b) Suggest a cable layout of connections between the building inside the campus.
(c) Suggest the placement of the following devices with justification:
(i) Switch
(ii) Repeater
(d) The organisation is planning to provide a high speed link with its head office situated in the Kolkata using a wired connection. Which of the following cable will be most suitable for this job?
(i) Optical fibre
(ii) Co-axial cable
(iii) Ethernet cable
(e) Consultancy is planning to connect its office in Faridabad which is more than 10 km from Head office. Which type of network will be formed?
Answer:
(a) The most suitable place to house the server is JAMUNA because it has maximum number of computers.
(b)
CBSE Sample Papers for Class 12 Computer Applications Set 7 with Solutions 8
(c) (i) Switches are needed in every building to share bandwidth in every building.
(ii) Repeaters may be skipped as per above layout, (because distance is less than 100 m) however, if building RAVI and building JAMUNA are directly connected, we can place a repeater there as the distance between these two buildings is more than 100 m.
(d) (ii) Co-axial cable
(e) MAN (Metropolitan Area Network)

CBSE Sample Papers for Class 12 Computer Science Set 7 with Solutions

Question 34.
(a) List the major components of database system. [1 + 4 = 5](b) Note the following to establish the connection between Python and MySQL:
A resultset is extracted from the database using the cursor object (that has been already created) by giving the following statement.
Mydata=cursor.fetchone( )
(i) How many records will be returned by fetchone() method?
(ii) What will be the datatype of Mydata object after the given command is executed?

Or

(a) What is join? What are the different kinds of joins?
(b) Define fetchmany([size]). How does fetchone() method differ from fetchall() method?
Answer:
(a) The major components of a database system are
(i) User
(ii) Hardware
(iii) Software
(iv) Data
(b) (i) fetchone() method retrieves the next row of a query result set and returns a single sequence, or none if rows are available. So one record will be returned by fetchone() method.
(ii) tuple is the datatype of Mydata object after the given command is executed. Tuples are used heterogeneous elements, which are elements belonging to different data types.

Or

(a) A join is a relational operation on a set of relations to get corresponding data from the table by linking them on a common field called the foreign key.
There are different kind of join:

(i) Equijoin
(ii) Natural join
(iii) Cross join
(iv) Non-equi join

(b) fetchmany([size]) returns the number of rows specified by the size argument. When called repeatedly this method fetches the next set of rows of a query result and returns a list of tuples. If no more rows are available, it returns an empty list.
fetchone () method returns the next row from the result set as tuple while fetchall ()fetches all the rows of a query result.

Question 35.
(a) What are the advantages of CSV files? [2 + 3 = 5](b) Write a Python program using following functions to :
A file “teacher.csv” contains a city, teacher name and Salamount.
Search() Search and print all rows where city is “delhi”.

Sample “teacher.csv” :
CBSE Sample Papers for Class 12 Computer Applications Set 7 with Solutions 6
Searchfromfile() From the file “teacher.csv” print all rows where teacher name is “Anil”.

Or

(a) What are the disadvantages of CSV files?
(b) Somya, wants to write the code for opening the binary file “hotel.dat” and write records of customer’s roomid, name and days of stay.
Answer:
(a) Advantages of CSV
(i) CSV ¡s faster to handle
(ii) CSV is smaller in size and is easy to generate

(b)

import csv
def Search( ):
f = open(Mteacher.csv, ‘r’)
r = csv.reader(f, delimiter = ‘,‘)
for row in r :
if row[0].lower()==delhi :
print(row[1], row[2])
f.close()
def Searchfromfile( ):
f = open(teacher.csv0, ‘r’)
r = csv.reader(f, delimiter = ‘,‘)
for row in r :
if “Anil" in row[1] :
print(row[1], row[2])
f.close()
Search()
Searchfromfile()

Or

(a) Disadvantages of CSV files are
(i) There is no standard way to represent the binary data
(ii) There is no distinction between text and numeric values

(b)

import pickle
hotel lst=[]
cname=" "
days=0.0
roomid=0
ans=’y’
f=open("hotel.dat", "wb")
print(”Welcome to my Hotel “)
while ans==’y’:
roomid=input(Enter RoomId :")
cname=input(”Enter Customer name :“)
days=float(input("Enter days of stay :"))
hotellst=[roomid, cname, days)
pickle.dump(hotel lst,f)
ans=input(“Continue(y/n)")
f.close()


Show More
यौगिक किसे कहते हैं? परिभाषा, प्रकार और विशेषताएं | Yogik Kise Kahate Hain Circuit Breaker Kya Hai Ohm ka Niyam Power Factor Kya hai Basic Electrical in Hindi Interview Questions In Hindi