Class 12 CS 083 Previous Year Question Paper 2023 – Solution

Series ƩHEFG
Question Paper Code 91 Set 4

COMPUTER SCIENCE – SOLUTION
(Session 2022-23)

Time allowed : 3 hours
Maximum Marks : 70

General Instructions :

  1. This question paper contains five sections, Section A to E.
  2. All questions are compulsory.
  3. Section A have 18 questions carrying I nark each.
  4. Section B has 7 Very Short Answer type questions carrying 2 marks each.
  5. Section C has 5 Short Answer type questions carrying 3 marks each.
  6. Section D has 3 Long Answer type questions carrying 5 marks each.
  7. Section E has 2 questions carrying 4 marks each. One internal choice is
  8. All programming questions are to be answered using Python Language only.

SECTION – A

1. State True or False.
“Identifiers are names used to identifya variable, function in a program”.
Answer: True

2. Which of the following is a valid keyword in Python ?
a) false
b) return
c) non_local
d) none

3. Given the following Tuple
Tup= (10, 20, 30, 50)
Which of the following statements will result in an error ?
a) print (Tup [0])
b) Tup. insert (2,3)
c) print (Tup (1:2])
d) print (len (Tup))

4. Consider the given expression:
5<10 and 12>7 or not 7>4
Which of the following will be the correct output, if the given expression is
evaluated ?

a) True
b) False
c) NONE
d) NULL

5. Select the correct output of the code:
S= “Amrit Mahotsav @ 75”
A=S.partition (” “)
print (a)
a) ( ‘Amrit Mahotsav ‘, “@’, 75′)
b) [‘Amrit’, ‘Mahotsav’,’@,75′]
c) (‘Amrit’, ‘ Mahotsav @ 75’)
d) (‘Amrit’,’Mahotsay @ 75′)

6. Which of the following mode keeps the file ofset position at the end of the file ?
a) r+
b) r
c) w
d) a (append mode)

7. Fill in the blank.
____ function is used to arrange the elements of a list in ascending order.
a) sort()
b) arrange ()
c) ascending ()
d) asort ()

8. Which of the following operators will return either True or False ?
a) +=
b) !=
c) =
d) *=

9. Which of the following statement(s) would give an error after executing the following code?
Class-12-CS-083-Previous-Year-Question-Paper-2023-Q.9
a) Statement 2
b) Statement 3
c) Statement4
d) Statements 2 and 4

10. Fill in the blank.
____ is a number of tuples in a relation.
a) Attribute
b) Degree
c) Domain
d) Cardinality

11. The syntax of seek() is :
file_object.seek (offset [,reference_point])
What is the default value of reference_point ?
a) 0
b) 1
c) 2
d) 3

12. Fil in the blank :
____ clause is used with SELECT statement to display data in a sorted form with respect to a specified column.
a) WHERE
b) ORDER BY
c) HAVING
d) DISTINCT

13. Fill in the blank :
____ is used for point-to-point communication or unicast communication such as radar and satellite.
a) INFRARED WAVES
b) BLUETOOTH
c) MICROWAVES
d) RADIOWAVES

14. What will the following expression be evaluated to in Python ?
print (4+3*5/3-5%2)
a) 8.5
b) 8.0
c) 10.2
d) 10.0

15. Which function returns the sum of all elements of a list ?
a) Count ()
b) Sum ()
c) total ()
d) add ()

16. fetchall() method fetches all rows in a result set and returns a:
a) Tuple of lists
b) List of tuples
c) List of strings
d) Tuple of strings

Q. 17 and 18 are ASSERTION (A) and REASONING (R) based questions. Mark the correct choice as
(a) Both (A) and (R) are true and (R) is the correct explanation for (A).
(b) Both (A) and (R) are true and (R) is not the correct explanation for (A).
(c) (A is true but (R) s false.
(d) (A) is false but (R) is true.

17. Assertion (A): To use a function from a particular module, we need to import the module.
Reason (R): import statement can be written anywhere in the program, before using a function from that module.
Answer: (a) Both (A) and (R) are true and (R) is the correct explanation for (A).
Explanation: Assertion (A) is true because to use a function from a particular module in Python, you need to import that module using the import statement.
Reasoning (R) is also true because you can place the import statement anywhere in your program before using a function from the module.

18. Assertion (A) : A stack is a LIFO structure.
Reason (R) : Any new element pushed into the stack always gets positioned at the index after the last existing element in the stack.
Answer: (a) Both (A) and (R) are true and (R) is the correct explanation for (A).
Explanation: Assertion (A) is true because a stack is indeed a Last-In-First-Out (LIFO) structure, meaning the last element added is the first one to be removed.
Reasoning (R) is true because, in a stack, any new element pushed onto the stack gets positioned after the last existing element. This positioning follows the LIFO principle, confirming the assertion.

SECTION – B

19. Atharva is a Python programmer working on a program to find and return the maximum value from the list. The code written below has syntactical errors. Rewrite the correct code and underline the corrections made.
def max num (L) :
max=L(0)
for a in L :
if a > maX
max=a
return maX

def max_num(L):
    max_value = L[0]  # Correction: Changed 'max' to 'max_value' and used square brackets to access the first element.
    for a in L:
        if a > max_value:  # Correction: Changed 'maX' to 'max_value' and added a colon at the end of the 'if' line.
            max_value = a  # Correction: Changed 'max' to 'max_value'.
    return max_value  # Correction: Changed 'maX' to 'max_value'.

20. (a) Differentiate between wired and wireless transmission.

DifferencesWired TransmissionWireless Transmission
Physical ConnectionWired transmission uses physical cables or wires to transmit data.Wireless transmission does not use physical cables.
ReliabilityWired connections are generally more reliable and less susceptible to interference or signal loss.Wireless connections offer mobility and flexibility as they allow devices to connect without being tethered to a specific location.
SpeedWired connections often offer higher data transfer speeds compared to wireless.Wireless connections may still be slower than certain wired connections
SecurityWired networks can be more secure than wired networksWireless networks can be less secure than wired networks
InstallationInstalling wired connections may require drilling holes and running cables, which can be time-consuming and less flexible for device placement.Setting up wireless connections is relatively easy and convenient, with no need for physical cables.

OR
(b) Differentiate between URL and domain name with the help of an appropriate example.

URL (Uniform Resource Locator)Domain Name
A URL is a complete web address that specifies the protocol, domain name, and the path to a specific resource on the internet.A domain name is a part of a URL that represents the human-readable name for a website or an internet resource.
It includes elements like the protocol (e.g., http, https), domain name, path, and possibly query parameters or fragments.It is a text-based address used to access websites and resources on the internet.
A URL can point to a specific webpage or a specific resource (e.g., an image, video, document) on a website.A domain name is used to locate a specific web server where a website is hosted.
Example of a URL: “https://learncse.in/wp-content/uploads/2023/09/Dangers-of-Sharing-Your-Kids-Pictures-Online-What-Parents-Need-to-Know.jpgExample of a Domain Name: “www.learncse.in

21. (a) Given is a Python list declaration:
Listofnames= [ "Aman", "Ankit", "Ashish", "Rajan", "Rajat")
Write the output of:
print (Listofnames [-1:-4:-1] )
Answer: The output of this code will be a list of elements from the original list, sliced in reverse order as ['Rajat', 'Rajan', 'Ashish']

(b) Consider the following tuple declaration :
tupl=(10,20, 30, (10,20,30),40)
Write the output of :
print (tupl. index (20))
Answer: The output of this code will be the index of the first occurrence of the value 20 in the tuple tupl, which is at index 1 (0-based index):
So, the index of the value 20 in the tuple is 1.

22. Explain the concept of ‘Alternate Key’ in a Relational Database Management System with an appropriate example.
Answer: In a Relational Database Management System (RDBMS), an Alternate Key is a candidate key that is not selected as the primary key for a table. It serves as a unique identifier for records in a table but is not designated as the primary
Example: While you’ve chosen "Customer_ID" as the primary key, "Email_Address" can be used as an alternate key. This means that even though "Customer_ID" is the primary means of access, you won’t allow multiple customers to have the same email address in the database.

23. (a) Write the full forms of the following:
(i) HTML (ii) TCP
Answer: (i) HTML: Hyper-Text Markup language
(ii) TCP: Transmission Control Protocol

(b) What is the need of Protocols ?
Answer: Protocols are the rules and conventions that enable the seamless exchange of information in computer networks and other communication systems. Imagine they’re a bit like languages or codes that computers use to share information. These rules help them understand how to send and receive data, like when you send a message on the internet or make a call on your phone.

24. (a) Write the output of the code given below :
Class 12 CS 083 Previous Year Question Paper 2023 Q.24 (a)
Answer: Output: [‘CSCS’, ‘HINDIHINDI’, ‘PHYSICSPHYSICS’, ‘CHEMISTRYCHEMISTRY’, ‘MATHSMATHS’]
Explanation: In this code, the function short_sub doubles each subject in the list if its length is greater than 4 characters. When you call the function with short_sub(subject, 5), it modifies the subject list in place, doubling the subjects with more than 4 characters.
OR
(b) Write the output of the code given below :
Class 12 CS 083 Previous Year Question Paper 2023 Q.24 (b)
Answer: 40#45@
Explanation: In this corrected code, if a is even (which it is initially), 5 is added to a. If a is odd, x is reduced by the value of a. This is reflected in the output where the numbers are modified based on whether a is even or odd.

25. (a) Differentiate between CHAR and VARCHAR data types in SQL with appropriate example.
Answer: CHAR (Character) is a fixed-length data type. It always reserves a specified amount of storage space, regardless of the actual data length. If you define a CHAR(10) column, it will always use 10 characters’ worth of storage. If the data is shorter than the specified length, CHAR pads the remaining space with spaces.
Example: CHAR(10) would always use 10 characters for data, even if you store “John” in it, it would be stored as “John ” (with spaces).
VARCHAR (Variable Character) is a variable-length data type. It only uses as much storage space as the actual data length. If you define a VARCHAR(10) column and store “John” in it, it will use 4 characters’ worth of storage.
Example: VARCHAR(10) would use exactly as much storage as needed, so “John” would occupy 4 characters’ worth of storage.

OR
(b) Name any two DDL and any two DML commands.
Answer: DDL (Data Definition Language) Commands: CREATE & ALTER
DML (Data Manipulation Language) Commands: SELECT & INSERT

SECTION -C

26. Consider the following tables – LOAN and BORROWER:
Class 12 CS 083 Previous Year Question Paper 2023 Q.26 (a)
(a) How many rows and columns will be there in the natural join of these two tables ?
Answer: Natural join is when only common rows are displayed. Hence, 2 rows and 4 columns.
(b) Write the output of the queries i) to (iv) based on the table, WORKER given below :
Class 12 CS 083 Previous Year Question Paper 2023 Q.26 (b)
Answer: (i) TO (iv) Image will be updated

27. (a) Write the definition of a Python function named LongLines ( ) which reads the contents of a text file named 'LINES. TXT' and displays those lines from the file which have at least 10 words in it. For example, if the content of 'LINES.TXT' is as follows :
Once upon a time, there was a woodcutter
He lived in a little house in a beautiful, green wood.
One day, he was merrily chopping some wood.
He saw a little girl skipping through the woods, whistling happily.
The girl was followed by a big gray wolf.
Then the function should display output as :
He lived in a little house in a beautiful, green wood.
He saw a little girl skipping through the woods, whistling happily.

def LongLines():
    try:
        with open("LINES.TXT", 'r') as file:
            lines = file.readlines()
            
            for line in lines:
                words = line.split()
                if len(words) >= 10:
                    print(line.strip())
    except FileNotFoundError:
        print("File not found.")

# Call the function to display long lines
LongLines()

OR
(b) Write a function count_Dwords () in Python to count the words ending with a digit in a text file "Details.txt".
Example:
If the file content is as follows:
On seat2 VIP1 will sit and
On seat1 VVIP2 will be sitting
Output will be:
Number of words ending with a digit are 4

import re

def count_Dwords(file_path):
    try:
        with open(file_path, 'r') as file:
            text = file.read()
            words = text.split()

            count = 0
            for word in words:
                if re.search(r'\d$', word):
                    count += 1

            return count
    except FileNotFoundError:
        return -1  # Return -1 if the file is not found

# Provide the path to the text file
file_path = "Details.txt"

# Call the function to count words ending with a digit
result = count_Dwords(file_path)

if result == -1:
    print("File not found.")
else:
    print("Number of words ending with a digit are", result)

28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations COMPUTER and SALES given below :
Class 12 CS 083 Previous Year Question Paper 2023 Q.28 (a)
(b) Write the command to view all databases.

29. Write a function EOReplace() in Python, which accepts a list L of numbers. Thereafter, it increments all even numbers by 1 and decrements all odd numbers by 1.
Example:
If Sample Input data of the list is :
L= [10,20,30,40,35,55]
Output will be:
L=[11, 21,31, 41, 34, 54]

def EOReplace(L):
    for i in range(len(L)):
        if L[i] % 2 == 0:  # Check if the number is even
            L[i] += 1  # Increment even numbers by 1
        else:
            L[i] -= 1  # Decrement odd numbers by 1

# Sample Input data
L = [10, 20, 30, 40, 35, 55]

# Call the function
EOReplace(L)

# Print the modified list
print("Modified List:", L)

30. (a) A list contains following record of customer:
[Customer_name, Room Type]
Write the following user defined functions to perform given operations on the stack named 'Hotel' :
(i) Push_Cust () – To Push customers’ names of those customers who are staying in Delux Room Type.
(ii) Pop_Cust () – To Pop the names of customers from the stack and display them. Also, display “Underflow” when there are no customers in the stack.
For example:
If the lists with customer details are as follows:
["Siddarth"; "Delux"]
[ "Rahul", "Standard"]
["Jerry", "Delux"]
The stack should contain
Jerry
Siddharth

The output should be:
Jerry
Siddharth
Underflow

class HotelStack:
    def __init__(self):
        self.Hotel = []  # Initialize an empty stack

    def Push_Cust(self, customer_name, room_type):
        if room_type.lower() == "delux":
            self.Hotel.append(customer_name)

    def Pop_Cust(self):
        if len(self.Hotel) == 0:
            print("Underflow")
        else:
            customer = self.Hotel.pop()
            print(customer)

# Create a HotelStack object
hotel_stack = HotelStack()

# Customer records
customer_records = [
    ["Siddharth", "Delux"],
    ["Rahul", "Standard"],
    ["Jerry", "Delux"]
]

# Push customers staying in Delux Room Type
for record in customer_records:
    customer_name, room_type = record
    hotel_stack.Push_Cust(customer_name, room_type)

# Pop and display customer names
while len(hotel_stack.Hotel) > 0:
    hotel_stack.Pop_Cust()

OR
(b) Write a function in Python, Push (Vehicle) where, Vehicle is a dictionary containing details of vehicles – {Car Name: Maker}.
The function should push the name of car manufactured by TATA’ (including all the possible cases like Tata, TaTa, etc.) to the stack.

For example:
If the dictionary contains the following data:
Vehicle={"Santro": "Hyundai", "Nexon":"TATA", "Safari": "Tata")
The stack should contain
Safari
Nexon

def Push(Vehicle):
    stack = []  # Create an empty stack to store car names

    # Iterate through the dictionary
    for car, maker in Vehicle.items():
        if maker.lower() == "tata":
            stack.append(car)  # Push the car name to the stack (ignoring case)

    return stack

# Sample input dictionary
Vehicle = {"Santro": "Hyundai", "Nexon": "TATA", "Safari": "Tata"}

# Call the function
result_stack = Push(Vehicle)

# Print the stack
for car in result_stack:
    print(car)

SECTION- D

31. Quickdev, an IT based firm, located in Delhi is planning to set up a network for its four branches within a city with its Marketing department in Kanpur. As a network professional, give solutions to the questions (i) to (v), after going through the branches locations and other details which are given below :
Class 12 CS 083 Previous Year Question Paper 2023 Q.31-i
Distance between various branches is as follows:
Class 12 CS 083 Previous Year Question Paper 2023 Q.31-ii
Number of computers in each of the branches :
Class 12 CS 083 Previous Year Question Paper 2023 Q.31-iii
(i) Suggest the most suitable place to install the server for the Delhi branch with a suitable reason.
(ii) Suggest an ideal lavout for connecting al these branches within Delhi.
(iii) which device will you suggeat that should be placed in each of these branches to efficiently connect all the computers within these branches?
(iv) Delhi firm is planning to connect to its Marketing department in hanpur which is approximately 300 km away. Which type of network Out of LAN, WAN or MAN Will be formed ? Justify your answer.
(v) Suggest a protocol that shall be needed to provide help for transferring of files between Delhi and Kanpur branch.

32. (a) What possible output(s) are expected to be displayed on screen at the time of execution of the following program :
import random
M= [5,10, 15,20,25,30]
for i in range (1, 3) :
first=random. randint (2,5) - 1
sec=random. randint (3,6) - 2
third=random. randint (1, 4 )
print (M[first] ,M[ sec],M[third] , sep="#")

(i) 10#25#15
20#25#25
(ii) 5# 25#20
25#20#15
(iii) 30#20#20
20#25#25
(iv) 10#15#25#
15#20#10#


(b) The code given below deletes the record from the table employee which contains the following record structure:
E_code – String
E_name – String
Sal – Integer
City- String
Note the following to establish connectivity between Python and MySGQL:
Username is
 root
Password is root
The table exists in a MySQL database named emp.
The details (E code,E_name, Sal, City) are the attributes of the table.
Write the following statements to complete the code :
Statement 1 – to import the desired library.
Statement 2 – to execute the command that deletes the record with 
E_code as ‘El01’.
Statement 3 – to delete the record permanently from the database.

Class 12 CS 083 Previous Year Question Paper 2023 Q.32 (b)
OR

(a) Predict the output of the code given below:

Class 12 CS 083 Previous Year Question Paper 2023 Q.32 OR (a)

(b) Tne code given below reods the following records from the table employee and displavs only those records who have employees coming from city ‘Delhi’:}
E_code – String
E_name – String
Sal – Integer
City- String
Note the following to establish connectivity between Python and MySGQL:
Username is
 root
Password is root
The table exists in a MySQL database named emp.
The details (E code,E_name, Sal, City) are the attributes of the table.
Write the following statements to complete the code :
Statement 1 – to import the desired library.
Statement 2 – to execute the query that fetches records of the employees coming from city ‘Delhi’.
Statement 3 – to read the complete data of the query (rows whose city is Delhi) into the object named 
details, from the table employee in the database.
Class 12 CS 083 Previous Year Question Paper 2023 Q.32 OR (b)

33. (a) Write one difference between CSV and text files.
Write a program in Python that defines and calls the following user defined functions :
(i) 
COURIER ADD (): It takes the values from the user and adds the details to a csv file ‘courier.csv‘. Each record consists of a list with field elements as cid, s_name, Source, destination to store Courier ID, Sender name, Source and destination address respectively.
(ii) 
COURIER SEARCH (): Takes the destination as the input and displays all the courier records going to that destination.
(b) Why it is important to close a file before exiting ?
Write a progranm in Python that defines and calls the following user defined functions:
(i) Add_Book () : Takes the details of the books and adds them to a csv file ‘Book.csv’. Each record consists of a list with field elements as 
book_ID, B_name and pub to store book ID, book
name and publisher respectively.
(ii) Search_Book () : Takes publisher name as input and counts and displays number of books published by them.

SECTION – E

34. The school has asked their estate manager Mr. Rahul to maintain the data of all the labs in a table LAB. Rahul has created a table and entered data of 5 labs.
Class 12 CS 083 Previous Year Question Paper 2023 Q.34
Based on the data given above answer the following questions :
(i) Identify the columns which can be considered as Candidate keys.
(ii) Write the degree and cardinality of the table.
(iii) Write the statements to :
(a) Insert a new row with appropriate data.
(b) Increase the capacity of all the labs by 10 students which are on ‘I’ Floor.

OR (Option for part (iii) only)

(iii) Write the statements to :
(a) Add a constraint PRIMARY KEY to the column LABNO in the table
(b) Delete the table LAB.

35. Shreyas is a programmer, who has recently been given a task to write a user defined function named write_bin( ) to create a binary file called Cust_file.dat containing customer information – customer number (c_no), name (c_name), quantity (qty), price (price) and amount (amt) of each customer.
The function accepts customer number, name, quantity and price. Thereafter, it displays the message ‘Quantity less than 10…. Cannot SAVE’, if quantity entered is less than 10. Otherwise the function calculates amount as 
price*quantity and then writes the record in the form of a list into the binary file.
Class 12 CS 083 Previous Year Question Paper 2023 Q.35
(i) Write the correct statement to open a file ‘Cust_file.dat‘ for writing the data of the customer.
(ii) Which statement should Shreyas fill in Statement 2 to check whether quantity is less than 10.
(iii) Which statemnent should Shreyas fill in Statement 3 to write data to the binary file and in Statement 4 to stop further processing if the user does not wish to enter more records.


OR (Option for part (iii) only)

(iii) What should Shreyas fill in Statement 5 to close the binary file named Cust_file.dat and in Statement 6 to call a function to write data in binary file?

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