Students must start practicing the questions from CBSE Sample Papers for Class 12 Computer Science with Solutions Set 11 are designed as per the revised syllabus.
CBSE Sample Papers for Class 12 Computer Science Set 11 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]
“The pop() method removes and displays the last element of a list.”
Answer:
True
Question 2.
……… are drawn using certain special purpose symbols. [1]
(a) Algorithm
(b) Pseudocode
(c) Flowchart
(d) Decision table
Answer:
(c) Flowchart
Question 3.
The output of the code will be : [1]
L=[6,7,8,9,10] print(L[2:20])
(a) [8,9, 10]
(b) [ ]
(c) Error
(d) [6,7,8,9,10]
Answer:
(a) [8, 9, 10]
Question 4.
The random function returns a random value between [1]
(a) 1 and 10
(b) 0 and 10
(c) 0 and 1
(d) 1 and 100
Answer:
(c) 0 and 1
Question 5.
Given a tuple tup=(20,50,10,60,30). The statement t.append(90) returns [1]
(a) (20,50,10,60,30,90)
(b) (90)
(c) Error
(d) (30,90)
Answer:
(c) Error
Question 6.
To read three characters from a file object f, we use ………… [1]
(a) f.read(3)
(b) f.read()
(c) f.readline()
(d) f.readlines()
Answer:
(a) f.read(3)
Question 7.
To arrange a table in descending order of field Salary the clause to be used is
(a) Order by Salary
(b) Order by Salary Desc
(c) Arrange by SalaryDesc
(d) Arrange by Salary
Answer:
(b) Order by Salary Desc
Question 8.
The constraint that ensures that the field does not get any NULL values is
(a) NULL
(b) PRIMARY KEY
(c) CHECK
(d) NOT NULL
Answer:
(d) NOT NULL
Question 9.
‘is’ and ‘is not’ are ………….. operators.
(a) Membership
(b) Identity
(c) Logical
(d) Comparison
Answer:
(b) Identity
Question 10.
Which of the following are possible relational operations?
(a) Join
(b) Selection
(c) Cartesian product
(d) All of these
Answer:
(d) All of these
Question 11.
Fill in the blank : To open a text file for adding records keeping the existing records the mode should be ………. [1]
(a) ab
(b) xb
(c) rb
(d) w+
Answer:
(d) w+
Question 12.
Raghav is trying to write an object obj1 = (1,2,3,4,5) on a binary file “test.dat”. Consider the following code written by him. [1]
import pickle obj1 = (1, 2, 3, 4, 5) myfile = open(“test.dat”,‘wb’) pickle. _____ #Statement 1 myfile.close( ) Identify the missing code in Statement 1. (a) dump(myfile,obj1) (b) dump(obj1, file) (c) write(obj1, myfile) (d) load(myfile, obj1)
Answer:
(b) dump(obj1, myfile)
Question 13.
State whether the following statement is True or False : A device that connects two dissimilar networks is repeater.
Answer:
Flase
Question 14.
What will the following code display?
name = “Neha”
type (name)
(a) Invalid function
(b) <class ‘str’>
(c) <class ‘int’>
(d) <class ‘float’>
Answer:
(b) <class ‘str’>
Question 15.
Fill in the blank : Geometric arrangement of devices on the network is called …………
Answer:
topology
Question 16.
Identify the device which links two homogeneous packed broadcast local networks.
(a) Hub
(b) Router
(c) Bridge
(d) Gateway
Answer:
(c) Vridge
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) Default parameters to a function are not compulsory but are a good practice to specify. [1]
Reason (R) If default parameters are specified the formal parameters will take the default values, if any of the actual parameters are not passed.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for 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 for A.
Question 18.
Assertion (A) Python overwrites an existing file or creates a non-existing file when we open a file with ‘w’ mode. [1]
Reason (R) a+ mode is used only for writing operations.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A but R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true.
Answer:
(c) A is true but R is false.
Section – B
Question 19.
Identify the types of networks formed in the following cases : [1 + 1 = 2]
(a) Two friends sharing files between a distance of 1000 km.
(b) A device transmitting voice to stations within a distance of 30 km.
Or
(a) Which transmission media is commonly used in transporting multi-channel television signals in cities?
(b) In which topology, network components are connected to the same cable?
Answer:
(a) WAN – Wide Area Network
(b) MAN – Metropolitan Area Network
Or
(a) Co-axial cable
(b) Bus topology
Question 20.
Predict the output. [2]
(a) ‘wonders’.center(12, ’*’)
(b) ‘wonders25’.isalnum( )
Answer:
(a) ‘**wonders***’
(b) True
Question 21.
Given the following code : [2]
str1 = input (“Enter the string:”) final = "” for i in range(len(str1)): if (i%2 ==0): final = final + str1[i ] print(“Modified string is : ”, final) What is the above code doing?
Or
Consider the following list and answer the below questions.
l = [6, 9, 8, ‘Hi’, ‘Hello’, 45, 23, ‘New’]
(a) 1 [4: ]
(b) 1 [-4]
(c) 1 [2:5]
(d) ‘World’ in l
Answer:
The code removes the characters at the odd indices of a string. The loop iterates through the length of the string and checks the even positions. Extracts characters at these positions and creates a new string.
Or
(a) [‘Hello’, 45, 23, ‘New’]
(b) Hello
(c) [8, ‘Hi’, ‘Hello’]
(d) False
Question 22.
Write few advantages of SQL. [2]
Or
Write the output of the following queries, which are based on the table FURNITURE given below.
Table:FURNITURE
(a) SELECT SUM(DISCOUNT) FROM FURNITURE WHERE C0ST>15000;
(b) SELECT MAX(DATEOFPURCHASE) FROM FURNITURE; [2]
Answer:
Some advantages of SQL are as follows
(a) SQL is portable It is not platform dependent, it can be used in all types of devices; PCs, laptops and even mobile ‘ phones also.
(b) High speed SQL queries can be used to retrieve large amount of records from a database quickly and efficiently.
(c) Easy to learn and understand SQL generally consists of english language statements and it is very easy to learn and understand.
(d) SQL is used for relational database SQL is widely used for relational database.
Or
Question 23.
Explain the types of compile-time errors.
Answer:
Errors that occur during compile-time, are called compile-time errors. Two types of errors fall into categories of compile-time errors as
(a) Syntax errors These errors occur when rules of a programming language are misused. Syntax refers to formal rules governing the construction of valid statements in a language.
(b) Semantic errors These errors occur when statements are not meaningful. Semantic refers to the set of rules which give the meaning of statement.
Question 24.
Distinguish between tuple and list.
Or
How can you add following data in empty dictionary?
Keys | Values |
A | One |
B | Two |
C | Three |
D | Four |
Answer:
Differences between tuple and list are as follows
Tuple | List |
Elements of a tuple are immutable. | Elements of a list are mutable. |
Tuple is declared in parenthesis (). | List is declared in square brackets []. |
Tuples cannot be changed after creation. | Lists can be changed after creation. |
Iterating over the elements of a tuple is fast. | Iterating over the elements of a list is slow. |
Or
dic = {} dic[‘A’] = ‘One’ dic [‘B’] = ‘Two’ dic[ ‘C’ ] = ‘Three’ dic[‘D’] = ‘Four’
Question 25.
The code given below will give an error on execution. Identify the type of the error and modify j the code to handle such type of an error. [2]
x = int(input(“Enter the value of x : ”)) y = int(input("Enter the value of y : ”)) z = x/y print (“The value of z : ”, z)
Answer:
The error is run time error
x = int(input(“Enter the value of x : ”)) y = int(input(“Enter the value of y : ”)) if (y! = 0): z = x/y print (“The value of z : ”, z)
Section – C
Question 26.
Consider the tables EMP and SALGRADE storing details of employees and their salaries. [1 × 3 = 3]
Table: EMP
empno | ename | sal | date |
110 | Priya | 7000 | 11-11-2010 |
111 | Seeraa | 14000 | 15-02-2014 |
151 | Sachin | 30000 | 18-04-2015 |
142 | Deepa | 25000 | 20-05-2015 |
Table: : SALGRADE
empno | city | lowsal | hisal | grade |
110 | Delhi | 5000 | 10000 | 2 |
111 | NCR | 11000 | 13000 | 1 |
142 | Meerut | 10000 | 20000 | 5 |
With respect to the tables given above, write commands for the following :
(a) To display the average salaries of all employees who are not from Delhi.
(b) To display maximum salary from the EMP table among employees whose date is after “2014”.
(c) To find the count of employees who are from “Delhi”.
Answer:
(a) SELECT AVG(sal) FROM EMP t1, SALGRADE t2 WHERE t1.empno=t2.empno AND NOT t2.city=”Delhi”;
(b) SELECT MAX(sal) FROM EMP WHERE date> “2014-12-31”;
(c) SELECT COUNT(*) FROM EMP tl , SALGRADE t2 WHERE tl.empno=t2.empno AND t2.city =”Delhi”;
Question 27.
Write a method Filterwords() to find and display words from a text file ‘NewsLetter.txt’ whose length is less than 4. [3]
Or
Write a method countAN() that checks the number of occurrence of “A” and “N” in a text file “Story.txt”.
Answer:
def Filterwords(): c=0 file=open(‘NewsLetter.txt’,’r’) line=file.read() word=line.split(‘ ’) for c in word: if len(c)<4: print(c) file.close()
Or
def countAN(): countA=0 countN=0 file=open(“Story.txt", "r”) data=file.read() for ch in data : if ch in “A” : countA+=1 elif ch in “N” : countN+=1 print(“Number of A :" , countA) print(“Number of N :" , countN) file.close( )
Question 28.
Given the following tables for a database LIBRARY [1 × 3 = 3]
Write SQL commands (a) to (c) with respect to the table BOOKS
TABLE: BOOKS
(a) To show Book name, Author name and Price of books of EPB Publishers.
(b) To list the names from books of Fiction type.
(c) To display the names and price of the books in descending order of their price.
Answer:
(a) SELECT Book_Name, Author_Name, Price FROM BOOKS WHERE Publishers = ‘EPB’;
(b) SELECT Book_Name FROM BOOKS WHERE Type = ‘Fiction’;
(c) SELECT Book_Name, Price FROM BOOKS ORDER BY Price DESC;
Question 29.
Write user defined function patterns(n) to display the following pattern for n lines , as per the number passed to the function. The number to be input in main() function. [3]
Example:
Enter a number:6
6
66
666
6666
66666
666666
Enter a number:7
7
77
777
7777
77777
777777
Answer:
def patterns(n): for i in range(1, n+1): for j in ranged (1, (i+1)): print(n, end=' ') print( ) def main( ): n=int(input("Enter a number :")) patterns(n) main( )
Question 30.
A linear stack called status contains the following information : [3]
Phone number of Employee
Name of Employee
Write the following methods to perform given operations on the stack status :
Push_element ( ) To Push an object containing Phone number of Employee and Name of Employee into the stack.
Pop_element () To Pop an object from the stack and to release the memory.
Answer:
defPush_element (Status, Top) : phone_no = int (input(“Enter phone number :”)) emp_name = input (“Enter employee name :”) St = (phone_no, emp_name) Status.append (St) Top =Top + 1 return Top def Pop_element (Status, Top) : Slen = len (Status) if (Slen <= 0) : print (“Status is empty”) : else : phone_no, emp_name = Status. Pop ( ) Top = Top - 1 print(“Phone number %s and name %s deleted” % (phone_no, emp_name)) return Top
Section – D
Question 31.
Consider the following table [1 × 4 = 4]
TABLE: PATIENTS
(a) Write command to remove the records of “Cardiology” department.
(b) Display a report showing Name, charges and discount (15%) for all patients.
(c) Display names of female patients.
(d) Display the detail of patients.
Answer:
(a) DELETE FROM PATIENTS WHERE Department=”Cardiol ogy”;
(b) SELECT Name, Charges, Charges*0.15 AS “Discount” FROM PATIENTS;
(c) SELECT Name FROM PATIENTS WHERE Sex=”F”;
(d) SELECT * FROM PATIENTS;
Question 32.
Write a function to write data into binary file marks.dat and display the records of students from file marks.dat, who scored more than 95 marks. [4]
The structure of marks.dat is:
[rn, sname, marks]
Where,
rn – roll no of student
sname – name of student
marks – marks of student
Answer:
import pickle def search_95plus( ): f = open("marks.dat","ab") while True: rn=int(input("Enter the rollno:")) sname=input("Enter the name:") marks=int(input("Enter the marks:")) rec=[] data=[rn,sname,marks] rec.append(data) pickle.dump(rec, f) ch=input("Wnat more records?Yes:") if ch.lower( ) not in 'yes': break f.close() f = open("marks.dat","rb") cnt=0 try: while True: data = pickle.load(f) for s in data: if s[2]>95: cnt+=1 print("Record:",cnt) print("Roll NO:",s[0]) print("Name:",s[1]) print("Marks:",s[2]) except Exception: f.close( ) search_95plus( )
Section – E
Question 33.
G.R.K International Inc. is planning to connect its Bengaluru Office Setup with its Head Office in Delhi. The Bengaluru Office G.R.K. Internationa
Resource tol Inc. is spread across an area of approx. 1 square kilometres consisting of 3 blocks. Human Resources, Academics and Administration. You as a network expert have to suggest answers to the questions (a) to (e) raised by them.
Note Keep the distances between blocks and number of computers in each block in mind, while providing them the solutions. [1 × 5 = 5]
Shortest distances between various blocks
Human Resource to Administration | 100m |
Human Resource to Academics | 65m |
Academics to Administration | 110m |
Delhi Head Office to Bengaluru Office Setup | 2350 km |
Number of computers installed at various blocks
Block | Number of Computers |
Human Resources | 155 |
Administration | 20 |
Academics | 100 |
Delhi Head Office | 20 |
(a) Suggest the most suitable block in the Bengaluru Office Setup to host the server. Give a suitable reason with your suggestion.
(b) Suggest the cable layout among the various blocks within the Bengaluru Office Setup for connecting the blocks.
(c) Suggest the placement of switch.
(d) Suggest the most suitable media to provide secure, fast and reliable data connectivity between Delhi Head Office and the Bengaluru Office Setup.
(e) Expand the following
WAN LAN
Answer:
(a) Human Resources, because it has maximum number of computers.
(b)
(c) Switches are needed in every building as they share bandwidth in every building.
(d) Satellite
(e) WAN – Wide Area Network _ LAN – Local Area Network
Question 34.
(a) What is equi join? [1 + 4 = 5]
(b) Consider the table Faculty whose columns’ name are
F_ID, Fname, Lname, Hire_date, Salary, Course_name
Write the code to insert the following record into the above table.
101 | Riya | Sharma | 12-10-2004 | 35000 | Java Advance |
102 | Kiyaan | Mishra | 3-12-2010 | 28000 | Data Structure |
Or
(a) Identify which of the functions given below are aggregate functions.
COUNT(), LEFT(), RIGHT(), MAX(), AVG(), TRIM()
(b) What is the utility of fetchall() method? Write a code to fetch all the records of a Student table from PythonDB Database.
Note :
Host: localhost
Database : PythonDB
User : root
Password: arihant
Table : Student
Answer:
(a) Equi join is a simple SQL join condition that uses equal sign as a comparison operator.
Syntax
SELECT col 1, col2, col3 FROM table1, table2 WHERE tablet.col1 = table2.col1;
(b)
import mysql.connector mycon = mysql.connector.connect (host = “localhost”, user = “root”, passwd = “system”, database = “Test”) cursor = con.cursor ( ) sql = “INSERT INTO Faculty (F_ID, Fname, Lname, Hire_date, Salary, Course_Name) VALUES (%s, %s, %s, %s, %s, %s)” val = [(101, 'Riya', ‘Sharma’, ‘12-10-2004', 35000, ‘Java Advance’), (102, ‘Kiyaan’, ‘Mishra’, ‘3-12-2010’, 28000, ‘Data Structure’)] try: cursor.executemany (sql, val) mycon.commit ( ) except : mycon.roll back ( ) mycon.close ( )
Or
(a) Aggregate functions are
COUNT(), MAX(), AVG()
(b)
import mysql.connector con = mysql.connector.connect (host = “localhost", user = “root”, passwd = “arihant”, database = “PythonDB”) cursor = con.cursor() try : cursor.execute (“Select *from Student”) display = cursor.fetchall() for i in display : print(i) except : con.roll back () con.close()
Question 35.
(a) Which file can be opened with notepad as well as MS Excel? [2 + 3 = 5]
(b) A CSV file “Garment.csv” file exists containing records of different types of garments as per following structure.
GarmentID Type Gender Cost
Write a python program to add and search records of garments from the csv file and display using the following functions :
AddGarment() Function to input details of garments and store them to the file “Garment.csv”, if the garment type is “cotton” or “silk”.
ShowGarments() To open the file ” Garment.csv”, display details and number of “silk” garments
Or
(a) What is with statement in Python?
(b) A csv file “cricket.csv” exists to store data of cricketers as follows:
CID CricketerName Strikerate WorldRank
Write a program in python to add data of more cricketers along with the existing records. Also display the details of cricketers as per the condition given using the functions:
AppendCricketer() To accept data of cricketers and append them to the file “cricket.csv”
GetCricketers() To open the file “cricket.csv” and display number of cricketers whose world ranking is above 50.
Answer:
(a) CSV file
(b)
import pickle def AddGarment( ) : f=open(''Garment.csv ","wb") ans='y' gid=" " gtype=" " gen=" " gcost=0 . 0 while ans=='y': gid=input("Enter garment id.”) gtype=input(''Enter Garment type ") gen=input("Gender ") gcost=float(input(“Enter cost ”)) glst=[ gid, gtype, gen, gcost] if gtype==”cotton” or gtype==”silk” : pickle.dump(glst,f) else: print(“Invalid garment type!!!”) ans=input("Continue(y/n)") f.close( ) def ShowGarments( ) : count=0 f=open("Garment.csv","rb") while True: try: glst=pickle.load (f) if glst[1]="silk": count+=1 print("Garment ID.:", ,glst[0]) print("Garment Type : ", glst[1]) print("Gender:", glst[2]) print("Price :", glst[3]) print("No. of silk garments":, count) except EOFError: print("End of file") break f.close( ) AddGarment( ) ShowGarments( )
Or
(a) with statement in Python is used in to simplify the management of common resources like file streams.
It makes the code cleaner and much more readable.
(b)
import pickle def AppendCricketer( ) : f=open("cricket.csv","ab") ans='y' cid=" " cname="" srate=0.0 wrank=0.0 while ans=='y': cid=input("Enter cricketer id.") cname=input("Enter cricketer name ") srate=float(input("Enter Strike rate : ")) wrank=int(input(“Enter world rank")) clst=[cid, cname, srate, wrank] pickle.dump(clst.f) ans=input("Continue(y/n) ”) f.close( ) def GetCricketers( ): count=0 f=open("cricket.csv","rb") while True: try: clst=pickle.load(f) if int(clst[3]) > 50 : count+=1 print("Number of cricketers above world rank 50 :” , count) except EOFError: break f.close( ) AppendCricketer() GetCricketers( )