Class 12 Computer Science (CS) Mid Term Oct 2022 Paper Solution


Wed Nov 2, 2022

Class 12 Computer Science (CS) Mid Term Oct 2022 Paper Solution



















19 - “ABC”, “DBA”, 35000

Q: 20: Write the difference between Switch and Router


1. Switch is a networking device.

2. Switch is a data link layer device.

3. Switch works in LAN (Local Area Network)

4. Switch works in same network.

5. Switch is an intra-network device

6. Switch use MAC (Media Access Control) address

7. Switch is an intelligent device

8. Data use as a frame format in switch.

9. Switch  use CAM (Content Accessable Memory) table

10. Switch usally used in 8/16/24/48 ports

11. Switch is a multiport device.

12. Switch is a full duplex device

13. No collision occurs in switch.

14. In switch every port has its collision table.

15. Switch support advanced features like VLAN, STP, RSTP etc.

16. Switch is faster than router.

17. Switch support 10 Mbps to 1 Gbps speed.


1. Router is a networking device.

2. Router is a Network Layer device.

3. Router works for WAN (Wide Area Network)

4. Router works for communication between different network.

5. Router is an inter network device.

6. Router use IP address

7. Data use as a packet in Router.

8. Router perform routing operation

9. Router use routing table.

10. Router usally support 2/4/8 etc ports

11. Router is slower than switch.

12. Router support 10 Mbps to 100 Mbps speed

Q: 21: Explain the three main parts of an optical fibre cable.


The three basic elements of a fiber optic cable are the core, the cladding and the coating.

A fibre optic cable contains three basic components: 

The core, which carries the light signals; 

The cladding, which surrounds the core with a lower refractive index and contains the light; and 

The coating, which protects the fragile core and cladding within it..


Write the difference between HTML and XML





HTML stands for Hypertext Markup Language

XML stands for Extensible Markup Language

Case insensitive

Case sensitive

Predefined Tags

User defined Tags

Used to Create Data

Used to Store and Transport Data

Format Driven

Content Driven

Q: 22: What will be the output of the following Python code snippet? 

x = 'abcd' 

for i in range(len(x)): 

    x = 'a' 







Q: 23: What is function? Explain the different types of functions

A function is a block of code which only runs when it is called. You can pass data, known as parameters, into a function. A function can return data as a result.

There are two types of functions: 

Built-in functions – 

These functions are pre-defined functions in Python. For Example: print(), input(), int(), float() etc.

User-defined functions – 

These functions are defined by the user to perform a specific task. 

Creating a Function

In Python a function is defined using the def keyword:

def my_function():
  print("Hello from a function")

Calling a Function

To call a function, use the function name followed by parenthesis:


Q: 24: Write the difference between drop, truncate and delete.


1. DDL

2. Can not be rollback

3. Used to delete database, table, index etc completly with structure.


1. DDL

2. Can not be rollback

3. Delete all rows of the table at once.

4. Can not delete structure of the table.

5. Where keyword not used


1. DML

2. Can be rollback

3. Used to delete one or more rows from the table one by one.

4. Can be used with or without where clause

Q: 25: Select type of SQL Query (DDL, DML, DQL, TCL, DCL) 

(a) Alter (b) Update (c) Delete (d) Truncate


Alter - DDL

Update - DML

Delete - DML

Truncate - DDL

Q: 26: What is Argument? Explain different types of arguments with example.

  • Parameter: It is the variable listed inside the parentheses in the function definition.
  • Argument: It is a value sent to the function when it is called. It is data on which function performs some action and returns the result.
Types of function arguments
  1. Default argument
  2. Keyword arguments (named arguments)
  3. Positional arguments
  4. Arbitrary arguments (variable-length arguments *args and **kwargs)

Types of Arbitrary Arguments:

  • arbitrary positional arguments (*args)
  • arbitrary keyword arguments (**kwargs)
# function with variable-length arguments def percentage(*args): sum = 0 for i in args: # get total sum = sum + i # calculate average avg = sum / len(args) print('Average =', avg) percentage(56, 61, 73)

Q: 27: Write a function in Python to display the elements of list thrice if it is a number and display the element terminated with ‘#’ if it is not a number. 

For Example:

 L = [41,’Shiva’,’Saanvi’, 13, ‘Madhav’] 

The output should be 







 L = [41,’Shiva’,’Saanvi’, 13, ‘Madhav’] 

for word in L:

    if word.isdigit():




Q: 28: Write a function ETCount() in Python, which should read each character of a text file “TESTFILE.TXT” and then count and display the count of occurrence of alphabets E and T individually (including small cases e and t too). 

def ETCount() :

    file = open ('TESTFILE.TXT', 'r') 

     lines = file.readlines() 



     for w in lines : 

         for ch in w:

             if ch in 'Ee': 

                 countE = countE + 1 

             if ch in 'Tt': 

                 countT=countT + 1 

     print ("The number of E or e : ", countE) 

     print ("The number of T or t : ", countT) 


Q: 29: Write a function INDEX_LIST(L), where L is the list of elements passed as argument to the function. The function returns another list named ‘indexList’ that stores the indices of all Non-Zero Elements of L.



     for i in range(len(L)): 

         if L[i]!=0: 


     return indexList 

Q: 30:

(a) Write the query to display the name, Salary and Dept_name of each employee. 

select e.e_name,e.salary,d.dept_name from emp as e inner join dept as d on e.dept_no=d.dept_no;

(b) Find the average salary of employees. 

select avg(salary) from emp;

(c) Write the query to Increase the salary by 10% of each employee

update emp set salary=salary*0.1;

Q: 31: A linear stack called status contains the following information: 

(i) Phone number of Employee 

(ii) Name of Employee 

Write the following methods to perform given operations on the stack status: 

(i) Push_element ( ) To Push an object containing Phone number of Employee and Name of Employee into the stack.

 (ii) Pop_element ( ) To Pop an object from the stack and to release the memory. 

(iii) Display() To show all the elements of the stack


def Push_element():

     phone=input(*Enter the phone number: ")

    name=input("Enter the name of emp: ")



def Pop_element (): 

    if len(emp)==0: 

         print("Stack Empty") 


        print("Deleted Element: ", emp.pop())

def Display():





Q: 32: Learn Together is an educational NGO. It is setting up its new campus at Jabalpur for its web-based activities

(i) Suggest a cable layout of connections between the compounds. 

(ii) Suggest the most suitable place (i.e. compound) to house the server for this NGO. Also, provide a suitable reason for your suggestion. 

Training Compound - because it has maximum number of computers.

(iii) Suggest the placement of the following devices with justification: 

(a) Repeater (b) Hub/Switch 

Repeater: As per the above layout the repeater can be avoided as all distances between the compounds are <=100m

Hub/Switch - Training Compound as it is hosting the server.

(iv) The NGO is planning to connect its international office situated in Mumbai, which out of the following wired communication link, will you suggest for a very high speed connectivity? 

(a) Telephone analog line (b) Optical fibre (c) Ethernet cable. 

Optical fibre.

(v) Expand the following ● LAN ● PAN

LAN - Local Area Network

PAN - Personal Area Network

Q: 33: What is the advantage of using a csv file for permanent storage? Write a Program in Python that defines and calls the following user defined functions: 

(i) ADD() – To accept and add data of an employee to a CSV file ‘record.csv’. Each record consists of a list with field elements as empid, name and mobile to store employee id, employee name and employee salary respectively. 

(ii) COUNTR() – To count the number of records present in the CSV file named ‘record.csv’.

Advantage of a csv file: 

1. It is human readable – can be opened in Excel and Notepad applications 

2. It is just like text file 

import csv 

def ADD(): 



empid=int(input("Enter Employee id :: ")) 

 name=input("Enter name :: ") 

mobile=int(input("Enter mobile number :: ")) 




def COUNTR(): 








Q: 34: Write SQL commands for (i) to (iv) on the basis of the table SPORTS

(i) Display the games taken up by the students, whose name starts with ‘S’. 

Select game1,game2 from sports where name like 'S%';

(ii) Write a query to add a new column named MARKS. 

alter table sports add column marks float(5,2);

(iii) Write a query to assign a value 200 for Marks for all those, who are getting grade ‘B’ or grade ‘A’ in both GAME1 and GAME2. 

update sports set marks=200 where grade in ('A','B') and grade1 in ('A','B');

(iv) Write the command used to arrange the whole table in the alphabetical order of NAME? 

alter table sports add column marks float(4,2);

Q: 35: Write a menu driven program which insert, delete and display the details of a product such as pid, pname and price using Stack.



Launch your GraphyLaunch your Graphy
100K+ creators trust Graphy to teach online
S P SHARMA CLASSES 2023 Privacy policy Terms of use Contact us Refund policy