2023 CBSE Class 12 Computer Science Question Paper with Detailed Solutions

by Himanshu Garg

 

This is the Class 12 CBSE Final Term Computer Science Question Bank. The students’ challenges are met through a set of questions and answers that cut across all topics. The questions are divided into sections including multiple choice, very short answer, short answer and long answer questions so as to enhance the revision. Detailed answers are interspersed in any patient section that can be disclosed. Use this question bank for revising the concepts, practicing important questions or preparing for the final examination.

Note: These questions are based on the latest syllabus updates and include previous year questions for reference. Ensure to reshow the solved examples provided to grasp complex topics with ease.

Section A – Multiple Choice Questions (1 mark each)

  1. State True or False: Identifiers are names used to identify a variable, function in a program.
    SHOW ANSWER
    Answer: TrueExplanation: Identifiers are indeed names used in programming to identify variables, functions, classes, modules, etc.
  2. Which of the following is a valid keyword in Python?
    • (a) false
    • (b) return
    • (c) non_local
    • (d) none
    SHOW ANSWER

    Answer: b) return

    Explanation: “return” is a keyword in Python, whereas “false,” “non_local,” and “none” are not written correctly. The correct keywords would be “False,” “nonlocal,” and “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))
    SHOW ANSWER

    Answer: b) Tup.insert(2,3)

    Explanation: Tuples are immutable, so you cannot insert elements into them. The other operations are valid.

  4. Consider the given expression: 5 < 10 and 12 > 7 or not 7 > 4. What will be the correct output if the given expression is evaluated?
    • (a) True
    • (b) False
    • (c) NONE
    • (d) NULL
    SHOW ANSWER

    Answer: a) True

    Explanation: 5 < 10 is True, 12 > 7 is True, not 7 > 4 is False. True and True or False evaluates to True.

  5. Select the correct output of the following code:
    S = "Amrit Mahotsav@ 75"
    A = S.partition(" ")
    print(A)
    • (a) (‘Amrit Mahotsav’, ‘@’, ’75’)
    • (b) [‘Amrit’, ‘Mahotsav’, ‘@’, ’75’]
    • (c) (‘Amrit’, ‘Mahotsav@ 75’)
    • (d) (‘Amrit’, ‘Mahotsav@ 75′, ’75’)
    SHOW ANSWER

    Answer: c) (‘Amrit’, ‘Mahotsav@ 75’)

    Explanation: The partition() method splits the string at the first occurrence of the specified separator (space) and returns a tuple.

  6. Which of the following mode keeps the file offset position at the end of the file?
    • (a) r+
    • (b) r
    • (c) w
    • (d) a
    SHOW ANSWER

    Answer: d) a

    Explanation: The ‘a’ mode (append) opens the file for writing and sets the file pointer at the end of the file.

  7. Which function is used to arrange the elements of a list in ascending order?
    • (a) sort()
    • (b) arrange()
    • (c) ascending()
    • (d) asort()
    SHOW ANSWER

    Answer: a) sort()

    Explanation: The sort() function sorts the list in ascending order by default.

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

    Answer: b) !=

    Explanation: The != is a comparison operator that returns True if the values are not equal, otherwise False.

  9. Which statement(s) would give an error after executing the following code:
    Stud = {"Murugan": 100, "Mithu": 95}
    print(Stud[95])
    • (a) Statement 2
    • (b) Statement 3
    • (c) Statement 4
    • (d) Statements 2 and 4
    SHOW ANSWER

    Answer: a) Statement 2

    Explanation: The error occurs because 95 is not a key in the dictionary Stud. Dictionary keys are “Murugan” and “Mithu.”

  10. ___ is the number of tuples in a relation.
    • (a) Attribute
    • (b) Degree
    • (c) Domain
    • (d) Cardinality
    SHOW ANSWER

    Answer: d) Cardinality

    Explanation: Cardinality refers to the number of tuples (rows) in a relation (table), while degree refers to the number of attributes (columns).

  11. The syntax of seek() is: file object.seek(offset[, reference_point]). What is the default value of the reference point?
    • (a) 0
    • (b) 1
    • (c) 2
    • (d) 3
    SHOW ANSWER

    Answer: a) 0

    Explanation: By default, the reference point is 0, which means the offset is from the beginning of the file.

  12. ___ clause is used with the SELECT statement to display data in a sorted form with respect to a specified column.
    • (a) WHERE
    • (b) ORDER BY
    • (c) HAVING
    • (d) DISTINCT
    SHOW ANSWER

    Answer: b) ORDER BY

    Explanation: The ORDER BY clause is used to sort the data retrieved by the SELECT statement.

  13. ___ communication is used for point-to-point communication such as radar and satellite.
    • (a) INFRARED WAVES
    • (b) BLUETOOTH
    • (c) MICROWAVES
    • (d) RADIOWAVES
    SHOW ANSWER

    Answer: c) MICROWAVES

    Explanation: Microwaves are used for point-to-point communication like satellite communication.

  14. What will the following expression evaluate to:
    print(4 + 3 * 5 / 3 - 5 % 2)
    • (a) 8.5
    • (b) 8.0
    • (c) 10.2
    • (d) 10.0
    SHOW ANSWER

    Answer: b) 8.0

    Explanation: The expression follows the BODMAS rule, and the result is 8.0.

  15. Which function returns the sum of all elements of a list?
    • (a) count()
    • (b) sum()
    • (c) total()
    • (d) add()
    SHOW ANSWER

    Answer: b) sum()

    Explanation: The sum() function returns the sum of all the elements of a list.

  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
    SHOW ANSWER

    Answer: b) List of tuples

    Explanation: The fetchall() method returns a list of tuples, where each tuple represents a row from the result set.

  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.

    • (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) is false.
    • (d) (A) is false but (R) is true.
    SHOW ANSWER

    Answer: c) (A) is true but (R) is false

    Explanation: The import statement must be written at the top of the program, not just anywhere, before using a module’s function.

  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.

    • (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) is false.
    • (d) (A) is false but (R) is true.
    SHOW ANSWER

    Answer: b) Both (A) and (R) are true and (R) is not the correct explanation for (A).

    Explanation: While both statements are true, the reason does not explain the LIFO structure correctly.

Section B – Very Short Answer Questions (2 marks each)

  1. Rewrite the following code to correct syntactical errors:
    def max_num(L):
        max = L(0)
        for a in L:
            if a > max:
                max = a
        return max
    SHOW ANSWER

    Answer: Corrected code:

    def max_num(L):
        max_val = L[0]  # Use square brackets for list indexing, not parentheses
        for a in L:
            if a > max_val:
                max_val = a
        return max_val

    Explanation: The list elements should be accessed using square brackets (L[0] instead of L(0)). The variable “max” is a built-in function in Python, so it’s better to use a different name like max_val.

  2. Differentiate between wired and wireless transmission.
    SHOW ANSWER
    Answer:

    • Wired Transmission: It involves physical connections such as cables (e.g., Ethernet) to transmit data. Wired transmission is generally faster, more secure, and less prone to interference but limits mobility.
    • Wireless Transmission: It uses radio waves or infrared signals to transmit data (e.g., Wi-Fi, Bluetooth). Wireless transmission allows mobility and convenience but may face issues with speed, security, and interference.
  3. Differentiate between URL and domain name with the help of an example.
    SHOW ANSWER
    Answer:

    • Domain Name: It is the name that identifies a website on the Internet (e.g., example.com).
    • URL (Uniform Resource Locator): It is the complete address used to access a specific page or resource on a website. It includes the domain name along with other information like protocol, path, and parameters (e.g., https://www.example.com/page1.html).
  4. Consider the Python list:
    Listofnames = ["Aman", "Ankit", "Ashish", "Rajan", "Rajat"]

    Write the output of:

    print(Listofnames[-1::-4:-1])
    SHOW ANSWER

    Answer: [‘Rajat’, ‘Rajan’]

    Explanation: The slice [-1::-4:-1] starts from the last element (Rajat) and moves backwards by 1 element, skipping 4 elements in each step.

  5. Explain the concept of “Alternate Key” in a Relational Database Management System with an example.
    SHOW ANSWER
    Answer: An Alternate Key is a candidate key that is not chosen as the primary key. In a table, multiple columns may qualify as a unique identifier, but only one is selected as the primary key, and the others are considered alternate keys.Example: In a table STUDENT with columns StudentID, Email, and PhoneNumber, both Email and PhoneNumber could uniquely identify a student. If StudentID is chosen as the primary key, then Email and PhoneNumber become alternate keys.
  6. Write the full forms of:
    • (i) HTML
    • (ii) TCP
    SHOW ANSWER

    Answer:

    • HTML: HyperText Markup Language
    • TCP: Transmission Control Protocol
  7. Write the output of the following code:
    subject = ['CS', 'HINDI', 'PHYSICS', 'CHEMISTRY', 'MATHS']
    short_sub(subject, 5)
    print(subject)
    SHOW ANSWER

    Answer: The output depends on the implementation of the function short_sub(), which is not provided. If short_sub() modifies the list, the output will vary based on that modification.

Section C – Short Answer Questions (3 marks each)

  1. Differentiate between CHAR and VARCHAR data types in SQL with an example.
    SHOW ANSWER
    Answer:

    • CHAR(n): Fixed-length character data type. It always uses n characters, padding the string with spaces if the input is shorter.
    • Example: CHAR(5) will store “abc” as “abc “.
    • VARCHAR(n): Variable-length character data type. It only uses as much space as needed, up to n characters.
    • Example: VARCHAR(5) will store “abc” as “abc” without any padding.
  2. Consider the following tables – LOAN and BORROWER. How many rows and columns will be there in the natural join of these two tables?
    SHOW ANSWER
    Answer: The number of rows in the natural join will be equal to the number of matching rows between the two tables based on common columns. The number of columns will be equal to the total number of columns in both tables minus the duplicate columns used for the join.
  3. Write a Python function LongLines() that reads the contents of a text file and displays lines with at least 10 words.
    SHOW ANSWER
    def LongLines():
        with open('filename.txt', 'r') as file:
            lines = file.readlines()
            for line in lines:
                if len(line.split()) >= 10:
                    print(line)

    Explanation: The function reads all lines from the file. It splits each line into words and checks if the line contains at least 10 words before printing it.

  4. Write the SQL queries for:
    • SELECT MIN(PRICE), MAX(PRICE) FROM COMPUTER;
    • SELECT COMPANY, COUNT(*) FROM COMPUTER GROUP BY COMPANY HAVING COUNT(COMPANY) > 1;
    SHOW ANSWER

    Answer:

    • The first SQL query retrieves the minimum and maximum prices from the COMPUTER table.
    • The second SQL query counts the number of records for each company in the COMPUTER table, only returning companies with more than one record.
  5. Write a function EOReplace() in Python which accepts a list of numbers and increments all even numbers by 1 and decrements all odd numbers by 1.
    SHOW ANSWER
    def EOReplace(lst):
        for i in range(len(lst)):
            if lst[i] % 2 == 0:  # Even number
                lst[i] += 1
            else:  # Odd number
                lst[i] -= 1
        return lst

    Explanation: The function iterates over the list, checking each number for its parity. If the number is even, it is incremented by 1; if odd, it is decremented by 1.

Section D – Long Answer Questions (5 marks each)

  1. Write a function Push_Cust() to push customer names staying in ‘Delux’ room type in a stack, and Pop_Cust() to pop and display customer names.
    SHOW ANSWER
    stack = []
    
    def Push_Cust(customer_list):
        for customer in customer_list:
            if customer['room_type'] == 'Delux':
                stack.append(customer['name'])
    
    def Pop_Cust():
        while stack:
            print(stack.pop())

    Explanation: Push_Cust() adds customer names to the stack if their room type is ‘Delux.’ Pop_Cust() pops and prints customer names from the stack until it’s empty.

  2. An IT-based firm is planning to set up a network for its branches. Suggest an ideal layout to connect the branches and justify your choice.
    SHOW ANSWER
    Answer: The ideal layout would be a Star Topology using a central server.

    • Justification:
    • Centralized control: The server can efficiently manage communication between branches.
    • Scalability: New branches can be easily added to the network.
    • Reliability: If one branch fails, it won’t affect the others, unlike mesh topology.
  3. Write a program in Python that defines and calls the following user-defined functions:
    • COURIER_ADD(): Takes values from the user and adds them to a CSV file courier.csv.
    • COURIER_SEARCH(): Takes the destination as input and displays all the courier records going to that destination.
    SHOW ANSWER
    import csv
    
    def COURIER_ADD():
        with open('courier.csv', 'a', newline='') as file:
            writer = csv.writer(file)
            name = input("Enter courier name: ")
            destination = input("Enter destination: ")
            weight = input("Enter weight: ")
            writer.writerow([name, destination, weight])
    
    def COURIER_SEARCH():
        destination_input = input("Enter destination to search: ")
        with open('courier.csv', 'r') as file:
            reader = csv.reader(file)
            for row in reader:
                if row[1] == destination_input:
                    print(row)

Section E – Internal Choice Questions (4 marks each)

  1. The school has asked their estate manager Mr. Rahul to maintain the data of all the labs in a table LAB. Based on the data, identify the columns which can be considered as Candidate keys and write the degree and cardinality of the table.
    SHOW ANSWER
    Answer:

    • Candidate Keys: Any column(s) that can uniquely identify a lab, such as LabID or a combination of LabName and Location.
    • Degree: The number of columns in the table (e.g., if the table has 5 columns, the degree is 5).
    • Cardinality: The number of rows in the table, i.e., the number of labs.
  2. Write a user-defined function write_bin() to create a binary file called Cust_file.dat and store customer information (customer number, name, quantity, price, and amount).
    SHOW ANSWER
    import pickle
    
    def write_bin():
        with open('Cust_file.dat', 'wb') as file:
            customer = {}
            customer['number'] = input("Enter customer number: ")
            customer['name'] = input("Enter customer name: ")
            customer['quantity'] = int(input("Enter quantity: "))
            customer['price'] = float(input("Enter price: "))
            customer['amount'] = customer['quantity'] * customer['price']
            pickle.dump(customer, file)

Disclaimer

The question bank provided on this website is meant to be a supplementary resource for final term exam preparation. While we strive to offer accurate and relevant content, students should not rely solely on these answers. It is essential to conduct further research and consult teachers, school authorities, or subject experts to ensure thorough understanding and preparation. The solutions here are based on general interpretations and may not reflect the exact responses expected by examination boards. We are not responsible for any discrepancies or outcomes in exams resulting from the use of this material. By using this resource, you acknowledge that your academic success depends on comprehensive preparation, including active engagement with school materials and guidance from educators.

Leave a Reply

[script_15]

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. OK Read More

Privacy & Cookies Policy
-
00:00
00:00
Update Required Flash plugin
-
00:00
00:00
✓ Customized M.Tech Projects | ✓ Thesis Writing | ✓ Research Paper Writing | ✓ Plagiarism Checking | ✓ Assignment Preparation | ✓ Electronics Projects | ✓ Computer Science | ✓ AI ML | ✓ NLP Projects | ✓ Arduino Projects | ✓ Matlab Projects | ✓ Python Projects | ✓ Software Projects | ✓ Readymade M.Tech Projects | ✓ Java Projects | ✓ Manufacturing Projects M.Tech | ✓ Aerospace Projects | ✓ AI Gaming Projects | ✓ Antenna Projects | ✓ Mechatronics Projects | ✓ Drone Projects | ✓ Mtech IoT Projects | ✓ MTech Project Source Codes | ✓ Deep Learning Projects | ✓ Structural Engineering Projects | ✓ Cloud Computing Mtech Projects | ✓ Cryptography Projects | ✓ Cyber Security | ✓ Data Engineering | ✓ Data Science | ✓ Embedded Projects | ✓ AWS Projects | ✓ Biomedical Engineering Projects | ✓ Robotics Projects | ✓ Capstone Projects | ✓ Image Processing Projects | ✓ Power System Projects | ✓ Electric Vehicle Projects | ✓ Energy Projects Mtech | ✓ Simulation Projects | ✓ Thermal Engineering Projects

© 2024 All Rights Reserved Engineer’s Planet

Digital Media Partner #magdigit