Class 12 CS 083 Previous Year Question Paper 2020 – Compartment – Solution

Series HMJ/C
Question Paper Code 91/C Set 4

COMPUTER SCIENCE (NEW) – COMPARTMENT – SOLUTION
(Session 2019-20)

Time allowed : 3 hours
Maximum Marks : 70

General Instructions :

  1. All questions are compulsory.
  2. Question paper is divided into four sections – A, B, C and D.
    • Section A : Unit-1 – 30 Marks
    • Section B : Unit-2 – 15 Marks
    • Section C : Unit-3 – 15 Marks
    • Section D : Unit-4 – 10 Marks

SECTION A

1. (a) Which of the following is not a valid variable name in Python ? Justify reason for it not being a valid name.
(i) 5Radius
(ii) Radius_
(iii) _Radius
(iv) Radius
Answer: option (i) “5Radius” is not a valid variable name because it violates the rule that variable names cannot start with a number.

(b) Which of the following are keywords in Python ?
(i) break
(ii) check
(iii) range
(iv) while
Answer: Python keywords are reserved words that have special meanings in the language and cannot be used as variable names. So, the keywords in Python among the given options are (i) break, (iii) range, and (iv) while.

(c) Name the Python Library modules which need to be imported to invoke the following functions :
(i) cos()
(ii) randint()
Answer: To use the cos() function, you need to import the math module.
To use the randint() function, you need to import the random module.

(d) Rewrite the following code in Python after removing all syntax error(s). Underline each correction done in the code.
input('Enter a word',W)
if W = 'Hello'
print('Ok')
else:
print('Not Ok')

Answer: W = input('Enter a word: ') # Removed the incorrect variable assignment and added a colon after the input statement.
if W == 'Hello': # Replaced a single equals sign with a double equals sign for comparison.
print('Ok') # Indented the print statement properly.
else:
print('Not Ok') # Indented the print statement properly.

(e) Find and write the output of the following Python code :
def ChangeVal(M,N):
for i in range(N):
if M[i]%5 == 0:
M[i] //= 5
if M[i]%3 == 0:
M[i] //= 3
L=[25,8,75,12]
ChangeVal(L,4)
for i in L :
print(i, end='#')

Answer: The output of the code is: 5#8#5#4#

(f) Find and write the output of the following Python code :
def Call(P=40,Q=20):
P=P+Q
Q=P–Q
print(P,'@',Q)
return P
R=200
S=100
R=Call(R,S)
print (R,'@',S)
S=Call(S)
print(R,'@',S)

Answer: The output of the code is:
300 @ 200
120 @ 100
300 @ 120

(g) What possible output(s) are expected to be displayed on screen at the time of execution of the program from the following code ? Also specify the minimum and maximum values that can be assigned to the variable End.
Class 12 CS 083 Previous Year Question Paper 2020 - Compartment Q.1g

2. (a) Write the names of the immutable data objects from the following :
(i) List
(ii) Tuple
(iii) String
(iv) Dictionary

Answer: Immutable data objects are data types in Python that cannot be changed after they are created. Here are the immutable data objects from the above: (i) Tuple (ii) String

(b) Write a Python statement to declare a Dictionary named ClassRoll with Keys as 1, 2, 3 and corresponding values as ‘Reena‘, ‘Rakesh‘, ‘Zareen‘ respectively.
Answer: ClassRoll = {1: 'Reena', 2: 'Rakesh', 3: 'Zareen'}

(c) Which of the options out of (i) to (iv) is the correct data type for the variable Vowels as defined in the following Python statement ?
Vowels = ('A', 'E', 'I', 'O', 'U')
(i) List
(ii) Dictionary
(iii) Tuple
(iv) Array

(d) Write the output of the following Python code :
for i in range(2,7,2):
print(i * '$')

Answer: The output of the code is:
$$
$$$$
$$$$$$

(e) Write the output of the following Python code :
def Update(X=10):
X += 15
print('X = ', X)
X=20
Update()
print('X = ', X)

Answer: The output of the code is:
X = 25
X = 20

(f) Differentiate between ‘‘w’’ and ‘‘r’’ file modes used in Python. Illustrate the difference using suitable examples.
Answer: In Python, the file modes 'w' and 'r' are used to open files for writing and reading, respectively.

#Opening a file in 'w' mode and writing to it
with open('example.txt', 'w') as file:
file.write('This is a sample text written to the file.')
# Opening a file in 'r' mode and reading from it
with open('example.txt', 'r') as file:
    content = file.read()
    print(content)

(g) A pie chart is to be drawn (using python) to represent Pollution Level of Cities. Write appropriate statements in Python to provide labels for the pie slices as the names of the Cities and the size of each pie slice representing the corresponding Pollution of the Cities as per the following table :
Class 12 CS 083 Previous Year Question Paper 2020 - Compartment Q.2g

import matplotlib.pyplot as plt

# Data
cities = ['Mumbai', 'Delhi', 'Chennai', 'Bangalore']
pollution = [350, 475, 315, 390]

# Create a pie chart
plt.figure(figsize=(8, 8))
plt.pie(pollution, labels=cities, autopct='%1.1f%%', startangle=140)

# Set the aspect ratio to be equal so that it looks like a circle
plt.axis('equal')

# Add a title
plt.title('Pollution Level of Cities')

# Show the pie chart
plt.show()

OR

Write the output from the given Python code :
import matplotlib.pyplot as plt
Months = ['Dec','Jan','Feb','Mar']
Marks = [70, 90, 75, 95]
plt.bar(Months, Attendance)
plt.show()

(h) Write a function Show_words() in Python to read the content of a text file ‘NOTES.TXT’ and display the entire content in capital letters. Example, if the file contains :
"This is a test file"
Then the function should display the output as :
THIS IS A TEST FILE

def Show_words(file_name):
    try:
        # Open the file in read mode
        with open(file_name, 'r') as file:
            # Read the content of the file
            file_content = file.read()
            
            # Convert the content to uppercase
            file_content_upper = file_content.upper()
            
            # Display the content in uppercase
            print(file_content_upper)
    except FileNotFoundError:
        print(f"File '{file_name}' not found.")
    except Exception as e:
        print(f"An error occurred: {str(e)}")

# Example usage
Show_words('NOTES.TXT')

OR

Write a function Show_words() in Python to read the content of a text file 'NOTES.TXT' and display only such lines of the file which have exactly 5 words in them. Example, if the file contains :
This is a sample file.
The file contains many sentences.
But needs only sentences which have only 5 words.

Then the function should display the output as :
This is a sample file.
The file contains many sentences :

def Show_words(file_name):
    try:
        # Open the file in read mode
        with open(file_name, 'r') as file:
            # Read the content of the file line by line
            lines = file.readlines()

            # Iterate through each line
            for line in lines:
                # Split the line into words and count them
                words = line.split()
                word_count = len(words)

                # Check if the line has exactly 5 words
                if word_count == 5:
                    print(line.strip())  # Display the line without leading/trailing whitespace
    except FileNotFoundError:
        print(f"File '{file_name}' not found.")
    except Exception as e:
        print(f"An error occurred: {str(e)}")

# Example usage
Show_words('NOTES.TXT')

(i) Write a Recursive function in Python RecsumNat(N), to return the sum of the first N natural numbers. For example, if N is 10 then the function should return (1 + 2 + 3 + … + 10 = 55).

def RecsumNat(N):
    # Base case: If N is 1, return 1 (the sum of the first natural number)
    if N == 1:
        return 1
    # Recursive case: Add N to the sum of the first N-1 natural numbers
    else:
        return N + RecsumNat(N - 1)

# Example usage
N = 10
result = RecsumNat(N)
print(f"The sum of the first {N} natural numbers is {result}.")

OR

Write a Recursive function in Python Power(X,N), to return the result of X raised to the power N where X and N are non-negative integers. For example, if X is 5 and N is 3 then the function should return the result of (5)3 i.e. 125.

def Power(X, N):
    # Base case: X^0 is 1 for any positive X
    if N == 0:
        return 1
    # Recursive case: X^N = X * X^(N-1)
    else:
        return X * Power(X, N - 1)

# Example usage
X = 5
N = 3
result = Power(X, N)
print(f"{X}^{N} is {result}.")

(j) Write functions in Python for PushS(List) and for PopS(List) for performing Push and Pop operations with a stack of List containing integers.

#Here is the Python code for the 'PushS' function:
def PopS(stack, List):
    if stack: # if the stack is not empty
        for i in range(len(stack)):
            List.append(stack.pop()) # pop an element from the stack and add it to the list
    return List
#Here is the Python code for the 'PopS' function:
stack = []
list1 = ['1', '2', '3']
list2 = []

stack = PushS(stack, list1)
print(stack) # Output: [3, 2, 1]

list2 = PopS(stack, list2)
print(list2) # Output: [1, 2, 3]



OR

Write functions in Python for InsertQ(Names) and for RemoveQ(Names) for performing insertion and removal operations with a queue of List which contains names of students.

#Here is the Python code for the InsertQ function:

from collections import deque

def InsertQ(Names):
    queue = deque()
    for name in Names:
        queue.append(name)
    return queue
#Here is the Python code for the RemoveQ function:

def RemoveQ(Names):
    queue = InsertQ(Names)
    for name in Names:
        if name in queue:
            queue.remove(name)
    return queue

SECTION B

3. Fill in the blanks from questions 3(a) to 3(d).

(a) Computers connected by a network across different cities is an example of ____.
Answer: Wide Area Network (WAN)

(b) ____ is a network tool used to test the download and upload broadband speed.
Answer: Speedtest

(c) A ____ is a networking device that connects computers in a network by using packet switching to receive, and forward data to the destination.
Answer: Router

(d) ____ is a network tool used to determine the path packets taken from one IP address to another.
Answer: Traceroute

(e) Write the full form of the following abbreviations :
(i) POP – Post Office Protocol
(ii) VoIP – Voice over Internet Protocol
(iii) NFC – Near Field Communication
(iv) FTP – File Transfer Protocol

(f) Match the ServiceNames listed in the first column of the following table with their corresponding features listed in the second column of the table :
Class 12 CS 083 Previous Year Question Paper 2020 - Compartment Q.3f

(g) What is a secure communication ? Differentiate between HTTP and HTTPS.
Answer: Secure communication, also known as encryption, is a method of transmitting information between two parties over a communication channel in such a way that the information cannot be easily read, understood, or modified by anyone other than the intended recipient. It ensures data integrity, confidentiality, and authenticity of the sender and receiver.
HTTP (Hypertext Transfer Protocol) and HTTPS (Hypertext Transfer Protocol Secure) are both application layer protocols used for transmitting hypertext and other related data over the internet.

Difference: HTTP is an unsecured protocol, which means the data transmitted over it can be easily intercepted, read, or modified by a third party. On the other hand, HTTPS is a secure protocol that uses encryption to protect the data transmitted between the client and the server. It ensures that the communication between the client and the server is secure from eavesdropping and data tampering.

(h) Helping Hands is an NGO with its head office at Mumbai and branches located at Delhi, Kolkata and Chennai. Their Head Office located at Delhi needs a communication network to be established between the head office and all the branch offices. The NGO has received a grant from the national government for setting up the network. The physical distances between the branch offices and the head office and the number of computers to be installed in each of these branch offices and the head office are given below. You, as a network expert, have to suggest the best possible solutions for the queries as raised by the NGO, as given in (i) to (iv).
Distances between various locations in Kilometres :
Class 12 CS 083 Previous Year Question Paper 2020 - Compartment Q.3h-1
Number of computers installed at various locations are as follows :
Class 12 CS 083 Previous Year Question Paper 2020 - Compartment Q.3h-2
(i) Suggest by drawing the best cable layout for effective network connectivity of all the Branches and the Head Office for communicating data.

(ii) Suggest the most suitable location to install the main server of this NGO to communicate data with all the offices.

(iii) Write the name of the type of network out of the following, which will be formed by connecting all the computer systems across the network :
(A) WAN
(B) MAN
(C) LAN
(D) PAN

Answer: (A) WAN
WAN stands for Wide Area Network. It is a network that spans over a large geographical area, typically spanning cities, towns, and even countries. WANs are generally used for communication between remote locations, such as offices in different cities.

(iv) Suggest the most suitable medium for connecting the computers installed across the network out of the following :
(A) Optical fibre
(B) Telephone wires
(C) Radio waves
(D) Ethernet cable

SECTION C

4. (a) Which SQL command is used to add a new attribute in a table ?
Answer: ALTER TABLE with ADD clause

(b) Which SQL aggregate function is used to count all records of a table ?
Answer: COUNT

(c) Which clause is used with a SELECT command in SQL to display the records in ascending order of an attribute ?
Answer: ORDER BY

(d) Write the full form of the following abbreviations :
(i) DDL
Answer: DDL – Data Definition Language
(ii) DML
Answer: DML – Data Manipulation Language

(e) Observe the following tables, EMPLOYEES and DEPARTMENT carefully and answer the questions that follow :
Class 12 CS 083 Previous Year Question Paper 2020 - Compartment Q.4e
(i) What is the Degree of the table EMPLOYEES ? What is the cardinality of the table DEPARTMENT ?
(ii) What is a Primary Key ? Explain.
Answer: A primary key is a unique identifier for each record (row) in a relational database table. It ensures that each row has a distinct value for this key, and it enforces data integrity. For example, in a “Students” table, the “StudentID” column can serve as a primary key, ensuring each student has a unique identifier.

OR

Differentiate between Selection and Projection operations in context of a Relational Database. Also, illustrate the difference with one supporting example of each.

(f) Write whether the following statements are True or False for the GET and POST methods in Django :
(i) POST requests are never cached.
(ii) GET requests do not remain in the browser history.

(g) Write outputs for SQL queries (i) to (iii), which are based on the following tables, CUSTOMERS and PURCHASES :
Class 12 CS 083 Previous Year Question Paper 2020 - Compartment Q.4g
(i) SELECT COUNT(DISTINCT CITIES) FROM CUSTOMERS;
(ii) SELECT MAX(PUR_DATE) FROM PURCHASES;
(iii) SELECT CNAME, QTY, PUR_DATE FROM CUSTOMERS, PURCHASES WHERE CUSTOMERS.CNO = PURCHASES.CNO AND QTY IN (10,20);

(h) Write SQL queries for (i) to (iv), which are based on the tables : CUSTOMERS and PURCHASES given in the question 4(g) :
(i) To display details of all CUSTOMERS whose CITIES are neither Delhi nor Mumbai.
(ii) To display the CNAME and CITIES of all CUSTOMERS in ascending order of their CNAME.
(iii) To display the number of CUSTOMERS along with their respective CITIES in each of the CITIES.
(iv) To display details of all PURCHASES whose Quantity is more than 15.

SECTION D

5. (a) An organisation purchases new computers every year and dumps the old ones into the local dumping yard. Write the name of the most appropriate category of waste that the organisation is creating every year, out of the following options :
(i) Solid Waste
(ii) Commercial Waste
(iii) E-Waste
(iv) Business Waste

(b) Data which has no restriction of usage and is freely available to everyone under Intellectual Property Rights is categorised as
(i) Open Source
(ii) Open Data
(iii) Open Content
(iv) Open Education

(c) What is a Unique Id ? Write the name of the Unique Identification provided by Government of India for Indian Citizens.
Answer: In India, the government has introduced the Aadhaar system, which provides a unique identification number known as the “Aadhaar number” to Indian citizens.

(d) Consider the following scenario and answer the questions which follow :
“A student is expected to write a research paper on a topic. The student had a friend who took a similar class five years ago. The student asks his older friend for a copy of his paper and then takes the paper and submits the entire paper as his own research work.”
(i) Which of the following activities appropriately categorises the act of the writer ?
(A) Plagiarism
(B) Spamming
(C) Virus
(D) Phishing

(ii) Which kind of offense out of the following is made by the student ?
(A) Cyber Crime
(B) Civil Crime
(C) Violation of Intellectual Property Rights

(e) What are Digital Rights ? Write examples for two digital rights applicable to usage of digital technology.

(f) Suggest techniques which can be adopted to impart Computer Education for
(i) Visually impaired students (someone who cannot write).
(ii) Speech impaired students (someone who cannot speak).

Find Class 12 Computer Science Previous Year Question Papers

Find Class 12 Computer Science Previous Year Question Papers Solution

Find Class 12 Computer Science Previous Year Compartment Question Papers

Find Class 12 Computer Science Previous Year Compartment Question Papers Solution

Leave a Comment