2024 CBSE Class 12 Computer Science Question Paper with Detailed Solutions

by Engineer's Planet

As the CBSE board exams approach, students across the country are gearing up for one of the most important assessments of their academic journey. To help Class 12 Computer Science students prepare effectively, we have provided the 2024 CBSE Computer Science question paper along with detailed solutions. These solutions are designed to guide students through each question, offering clear explanations and insights to enhance their understanding and exam readiness.

Section A – Multiple Choice Questions (Each carries 1 mark)

  1. True or False: While defining a function in Python, the positional parameters in the function header must always be written after the default parameters.
    SHOW ANSWER
    Answer: False. In Python, positional parameters must always come before any default parameters in the function signature.
  2. The SELECT statement when combined with the ________ clause returns records without repetition:
    • (a) DISTINCT
    • (b) DESCRIBE
    • (c) UNIQUE
    • (d) NULL
    SHOW ANSWER

    Answer: (a) DISTINCT. The DISTINCT clause is used to return only distinct (different) values.

  3. What will be the output of the following statement:
    print(16*5/4*2/5-8)
    • (a) -3.33
    • (b) 6.0
    • (c) 0.0
    • (d) -13.33
    SHOW ANSWER

    Answer: (b) 6.0. The expression evaluates to 6.0 following order of operations.

  4. What possible output from the given options is expected to be displayed when the following Python code is executed?
    import random
    Signal = ['RED', 'YELLOW', 'GREEN']
    for K in range(2, 0, -1):
        R = random.randrange(K)
        print(Signal[R], end='#')
    • (a) YELLOW # RED #
    • (b) RED # GREEN #
    • (c) GREEN # RED #
    • (d) YELLOW # GREEN #
    SHOW ANSWER

    Answer: (b) RED # GREEN #. This code randomly selects indices from the Signal list and prints them.

  5. In SQL, the aggregate function which will display the cardinality of the table is ________.
    • (a) sum()
    • (b) count()
    • (c) avg()
    • (d) sum(*)
    SHOW ANSWER

    Answer: (b) count(). The COUNT() function counts the number of rows or distinct values in a table.

  6. Which protocol out of the following is used to send and receive emails over a computer network?
    • (a) PPP
    • (b) HTTP
    • (c) FTP
    • (d) SMTP
    SHOW ANSWER

    Answer: (d) SMTP. SMTP (Simple Mail Transfer Protocol) is used to send and receive emails.

  7. Identify the invalid Python statement from the following:
    • (a) d = dict()
    • (b) e = {}
    • (c) f = []
    • (d) g = dict{}
    SHOW ANSWER

    Answer: (d) g = dict{}. It is invalid because Python uses parentheses to initialize a dictionary.

  8. Consider the statements given below and choose the correct output from the given options:
    myStr = "MISSISSIPPI"
    print(myStr[:4] + "#" + myStr[-5:])
    • (a) MISS#SIPPI
    • (b) MISS#SIP
    • (c) MISS#IPPIS
    • (d) MISSI#IPPIS
    SHOW ANSWER

    Answer: (a) MISS#SIPPI. The slice [:4] gives “MISS” and [-5:] gives “SIPPI”.

  9. Identify the statement from the following which will raise an error:
    • (a) print(“A”*3)
    • (b) print(5*3)
    • (c) print(“15” + 3)
    • (d) print(“15” + “13”)
    SHOW ANSWER

    Answer: (c) print(“15” + 3). This will raise a TypeError since strings and integers cannot be concatenated without explicit conversion.

  10. Select the correct output of the following code:
    event = "G20 Presidency@2023"
    L = event.split(' ')
    print(L[::-2])
    • (a) [‘G20’]
    • (b) [‘Presidency@2023’]
    • (c) [‘G20’]
    • (d) ‘Presidency@2023’
    SHOW ANSWER

    Answer: (a) [‘G20’]. L[::-2] reverses the list and skips every other element.

  11. Which of the following options is the correct unit of measurement for network bandwidth?
    • (a) KB
    • (b) Bit
    • (c) Hz
    • (d) Km
    SHOW ANSWER

    Answer: (b) Bit. Network bandwidth is measured in bits per second (bps).

  12. Observe the given Python code carefully:
    a = 20
    def convert(a):
        b = 20
        a = a + b
    convert(10)
    print(a)
    • (a) 10
    • (b) 20
    • (c) 30
    • (d) Error
    SHOW ANSWER

    Answer: (b) 20. The value of a in the global scope is unchanged.

  13. True or False: While handling exceptions in Python, the name of the exception has to be compulsorily added with the except clause.
    SHOW ANSWER
    Answer: False. In Python, a generic except block without specifying the exception type can be used.
  14. Which of the following is not a DDL command in SQL?
    • (a) DROP
    • (b) CREATE
    • (c) UPDATE
    • (d) ALTER
    SHOW ANSWER

    Answer: (c) UPDATE. UPDATE is a DML (Data Manipulation Language) command, not a DDL command.

  15. Fill in the blank: _________ is a set of rules that needs to be followed by the communicating parties in order to have a successful and reliable data communication over a network.
    SHOW ANSWER
    Answer: Protocol. A protocol is a set of rules for communication over a network.
  16. Consider the following Python statement:
    F = open('CONTENT.TXT')

    Which of the following is an invalid statement in Python?

    • (a) F.seek(1, 0)
    • (b) F.seek(0, 1)
    • (c) F.seek(0, -1)
    • (d) F.seek(0, 2)
    SHOW ANSWER

    Answer: (c) F.seek(0, -1). Negative values for the second argument are invalid unless the file is opened in binary mode.

  17. Assertion (A): A CSV file is a human-readable text file where each line has a number of fields, separated by a comma or some other delimiter.Reason (R): The writerow() method is used to write a single row in a CSV file.
    • (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.
    SHOW ANSWER

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

  18. Assertion (A): The expression "HELLO".sort() in Python will give an error.Reason (R): The sort() method does not exist for strings in Python.
    • (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.
    SHOW ANSWER

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

 

Section B – Very Short Answer Questions (Each carries 2 marks)

  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: The correct code is:

    def max_num(L):
        max = L[0]
        for a in L:
            if a > max:
                max = a
        return max
  2. Differentiate between wired and wireless transmission.
    SHOW ANSWER
    Answer: Wired transmission uses cables like fiber optics or copper wires, whereas wireless transmission uses electromagnetic waves to transmit data.
  3. Differentiate between URL and domain name with the help of an example.
    SHOW ANSWER
    Answer: A domain name is part of the URL. For example, in https://www.example.com, ‘example.com’ is the domain name, while the full URL specifies the exact page and protocol.
  4. Consider the Python list: Listofnames = ["Aman", "Ankit", "Ashish", "Rajan", "Rajat"]. Write the output of:
    print(Listofnames[-1::-4:-1])
    SHOW ANSWER

    Answer: ‘Rajat’

  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 the primary key. For example, in a table where ‘ID’ is the primary key, ‘Email’ can be an alternate key.
  6. Write the full forms of:
    • (i) HTML
    • (ii) TCP
    SHOW ANSWER

    Answer: (i) HyperText Markup Language, (ii) 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 logic inside the short_sub function, which is not provided.

 

Section C – Short Answer Questions (Each carries 3 marks)

  1. Differentiate between CHAR and VARCHAR data types in SQL with an example.
    SHOW ANSWER
    Answer: CHAR stores fixed-length strings, while VARCHAR stores variable-length strings. Example: CHAR(5) stores exactly 5 characters, while VARCHAR(5) can store up to 5 characters.
  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: There will be 2 rows and 3 columns in the natural join of LOAN and BORROWER tables.
  3. Write a Python function LongLines() that reads the contents of a text file and displays lines with at least 10 words.
    SHOW ANSWER
    Answer:
    def LongLines():
        with open("LINES.TXT", "r") as file:
            for line in file:
                if len(line.split()) >= 10:
                    print(line)
  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 two SQL queries return the minimum and maximum price from the COMPUTER table, and the count of products per company having more than 1 product, respectively.

  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
    Answer:
    def EOReplace(L):
        for i in range(len(L)):
            if L[i] % 2 == 0:
                L[i] += 1
            else:
                L[i] -= 1

 

Section D – Long Answer Questions (Each carries 5 marks)

  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
    Answer: Implement the stack with Push_Cust() to add ‘Delux’ room customers and Pop_Cust() to remove and display customers.
  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: A star topology can be ideal to connect the branches with the main hub as it is easy to maintain and troubleshoot.
  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

    Answer:

    import csv
    def COURIER_ADD():
        with open("courier.csv", "a", newline="") as file:
            writer = csv.writer(file)
            cid = input("Enter Courier ID: ")
            s_name = input("Enter Sender Name: ")
            source = input("Enter Source: ")
            destination = input("Enter Destination: ")
            writer.writerow([cid, s_name, source, destination])
    def COURIER_SEARCH(destination):
        with open("courier.csv", "r") as file:
            reader = csv.reader(file)
            for row in reader:
                if row[3] == destination:
                    print(row)

 

Section E – Internal Choice Questions (Each carries 4 marks)

  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: LABNO. Degree: 4. Cardinality: 5.
  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
    Answer:
    import pickle
    def write_bin():
        with open("Cust_file.dat", "wb") as file:
            c_no = int(input("Enter Customer Number: "))
            c_name = input("Enter Customer Name: ")
            qty = int(input("Enter Quantity: "))
            price = float(input("Enter Price: "))
            amt = qty * price
            pickle.dump([c_no, c_name, qty, price, amt], 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.

✓ 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 

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