CBSE Class 12 Computer Science 01

CBSE SAMPLE PAPER-01 (2020-21)
Class 12 Computer Science

Maximum Marks: 70
Time Allowed: 3 hours

General Instructions:

  1. This question paper contains two parts A and B. Each part is compulsory.
  2. Both Part A and Part B have choices.
  3. Part-A has 2 sections:
    1. Section – I is short answer questions, to be answered in one word or one line.
    2. Section – II has two case study questions. Each case study has 4 case-based subparts. An examinee is to attempt any 4 out of the 5 subparts.
  4. Part – B is the Descriptive Paper.
  5. Part- B has three sections
    1. Section-I is short answer questions of 2 marks each in which two questions have internal options.
    2. Section-II is long answer questions of 3 marks each in which two questions have internal options.
    3. Section-III is very long answer questions of 5 marks each in which one question has an internal option.
  6. All programming questions are to be answered using Python Language only

 


  1. Part-A
    (Section-I)
  2. Attempt any 15 Questions from Questions 1 to 21.
  3. You have the following code segment:
    String1 = “my”
    String2 = “work”
    print(String1 + String2.upper())
    What is the output of this code?

    1. My Work
    2. mywork
    3. myWORK
    4. MY Work
  4. What will the following function return?
    def addEm(x, y, z):
    print(x + y + z)
  5. What does the rmdir() method do?
  6. What is the output of sys.platform [:2] if the code runs on windows operating system?
    1. ‘wi’
    2. Error
    3. ‘op’
    4. ‘sy’
  7. To open a file c:\res.txt for reading, we can use (select all correct options):
    1. file = open(“c: \res.txt”, “r”)
    2. file = open(“c:\ \res.txt”, “r”)
    3. file = open(r”c: \res.txt”, “r”)
    4. file = open(file = “c:\res.txt”, “r”)
    5. file = open(file = “c:\ \res.txt”, “r”)
    6. file = open(“c:\ \res.txt”)
    1. d, e, f
    2. a, e, f
    3. b, d, f
    4. b, c, f
  8. How can we find the names that are defined inside the current module?
  9. What is Connection? What is its role?
  10. How is module namespace organized in a Package?
  11. What is the output of the following?
    dry = {0: ‘a’, 1: ‘b’, 2: ‘c’}
    for x, y in dry. items():
    print(x, y, end = ‘ ‘)
  12. Which variables have global scope?
  13. When would you go for linear search in an array and when for binary search?
  14. Write a query to display the Sum, Average, Highest and Lowest salary of the employees.
  15. What are linear data structures?
  16. Consider the table with structure as:
    Student(ID, name, dept name, tot_cred)
    Which attribute will form the primary key?

    1. Dept
    2. ID
    3. Total credits
    4. Name
  17. Identify the Domain name and URL from the following: http://www.income.in/home.aboutus.htm
  18. SQL applies conditions on the groups through ________ clause after groups have been formed.
    1. Where
    2. Group by
    3. Having
    4. With
  19. What is database connectivity?
  20. What is the use of wildcard?
  21. What is a repeater?
  22. What is MySQLdb?
  23. The checksum of 1111 and 1111 is ________.
    1. 0000
    2. 1111
    3. 1110
    4. 0111
  24. Section-II (Case study based Questions)
  25. Give output for following SQL queries as per given table(s):Table: GRADUATE
    S.NO. NAME STIPEND SUBJECT AVERAGE DIV
    1. KARAN 400 PHYSICS 68 1
    2. DIVAKAR 450 COMPUTER SC 68 1
    3. DIVYA 300 CHEMISTRY 62 2
    4. ARUN 350 PHYSICS 63 1
    5. SABINA 500 MATHEMATICS 70 1
    6. JOHN 400 CHEMISTRY 55 2
    7. ROBERT 250 PHYSICS 64 1
    8. RUBINA 450 MATHEMATICS 68 1
    9. VIKAS 500 COMPUTER SC 62 1
    10. MOHAN 300 MATHEMATICS 57 2
    1. SELECT MIN (AVERAGE) FROM GRADUATE
      WHERE SUBJECT = “PHYSICS”;
    2. SELECT SUM(STIPEND) FROM GRADUATE WHERE DIV = 2;
    3. SELECT AVG(STIPEND) FROM GRADUATE WHERE AVERAGE >= 65;
    4. SELECT COUNT (distinct SUBJECT) FROM GRADUATE;
    5. Write code to rename a table in SQL
  26. If the file ‘poemBTH.txt’ contains the following poem (by Paramhans Yoganand):
    God made the Earth;
    Man-made confining countries
    And their fancy-frozen boundaries.
    But with unfound boundless Love
    I behold the borderland of my India
    Expanding into the World.
    Hail, mother of religions, Lotus, scenic beauty and sages!
    What outputs will be produced by both the code fragments given below:

    1. What outputs will be produced by the code fragment given below:
      my_file =open(‘poemBTH.txt’, ‘r’)
      my_file.read()
    2. What outputs will be produced by the code fragment given below:
      my_file = open(‘poemBTH.txt’, ‘r’)
      my_file.read(100)
    3. A __________ symbol is used to perform reading as well as writing on files in python.
    4. To open file data.txt for reading, open function will be written as f = _______.
    5. To open file data.txt for writing, open function will be written as f = ________.
  27. Part – B (Section-I)
  28. Write a program that rotates the elements of a list so that the element at the first index moves to the second index, the element in the second index moves to the third index, etc., and the element in the last index moves to the first index.
  29. What is Phishing? Explain with examples.ORGive the full form for the following:
    1. FM
    2. AM
    3. NFS
    4. FTP
  30. What do you mean by IP Address? How is it useful in Computer Security?
  31. Differentiate between fruitful functions and non-fruitful functions.ORPredict the output of the following code:
    a = 10
    y = 5
    def myfunc():
    y = a
    a = 2
    print “y =”, y ,”,a =”,a
    print “a + y = “, a + y
    return a + y
    print “y =”, y,”a =”,a
    print myfunc()
    print “y =”,y,”a =”,a
  32. Write a program that reads an integer N from the keyboard computes and displays the sum of the numbers from N to (2 * N) if N is nonnegative. If N is a negative number, then it’s the sum of the numbers from (2 * N) to N. The starting and ending points are included in the sum.
  33. Explain the Scope of Variables.
  34. Mr. Mittal is using a table with following columns :
    Name, Class, Streamed, Stream_name
    He needs to display names of students who have not been assigned any stream or have been
    assigned stream_name that ends with “computers
    He wrote the following command, which did not give the desired result.
    SELECT Name, Class FROM Students
    WHERE Stream_name = NULL OR Stream_name = “%computers” ;

    Help Mr. Mittal to run the query by removing the error and write correct query.
  35. What are data types? What are the main objectives of datatypes?
  36. What do you understand by Degree and Cardinality of a table?
  37. Find the errors in following code and write the correct code.
    if v < 5:
    for j in range(v):
    print “ABC”
    else:
    print “XYZ”

    1. Underline the corrections
    2. Write the reason!error next to it in comment form.
  38. Section- II
  39. Create file phonebook.dat that stores the details in following format:
    Name Phone
    Jivin 86666000
    Kriti 1010101
    Obtain the details from the user.
  40. Write a function which takes two string arguments and returns the string comparison result of the two passed strings.ORWrite a program that reads a date as an integer in the format MMDDYYYY. The program will call a function that prints print out the date in the format <Month Name><day>, <year>.
    Sample run :
    Enter date: 12252019
    December 25, 2019
  41. What is a package? How is a package different from the module?
  42. From the program code given below, identify the parts mentioned below :
    1. def processNumber(x):
    2.     x = 72
    3.     return x + 3
    4.
    5. y = 54
    6. res = processNumber(y)
    Identify these parts: function header, function call, arguments, parameters, function body, main program.
  43. Section-III
  44. Uplifting Skills Hub India is a knowledge and skill community which has an aim to uplift the standard of knowledge and skills in society. It is planning to set up its training centres in multiple towns and villages pan India with its head offices in the nearest cities. They have created a model of their network with a city, a town, and 3 villages as follows.
    As a network consultant, you have to suggest the best network related solutions for their issues/ problems raised in (i) to (iv) keeping in mind the distance between various locations and given parameters.

    The shortest distance between various location:

    VILLAGE 1 to B_TOWN 2 KM
    VILLAGE 2 to B_TOWN 1.0 KM
    VILLAGE 3 to B_TOWN 1.5 KM
    VILLAGE 1 to VILLAGE 2 3.5 KM
    VILLAGE 1 to VILLAGE 3 4.5 KM
    VILLAGE 2 to VILLAGE 3 2.5 KM
    A_CITY Head Office to B_HUB 25 KM

    The number of Computers installed at various locations is as follows:

    B_TOWN 120
    VILLAGE 1 15
    VILLAGE 2 10
    VILLAGE 3 15
    A_CITY Head OFFICE 6

    Note:
    In Villages, there are community centers, in which one room has been given as a training center for this organization to install computers.
    The organization has got financial support from the government and top IT companies.

    1. Suggest the most appropriate location of the SERVER in the B_HUB (out of the 4 locations), to get the best and effective connectivity. Justify your answer.
    2. Suggest the best-wired medium and draw the cable layout (location to location) to efficiently connect various locations within the B_HUB.
    3. Which hardware device will you suggest to connect all the computers within each location of B_HUB?
    4. Which service/protocol will be most helpful to conduct live interactions of Experts from Head Office and people at all locations of B_HUB?
  45. Consider the following tables STORE and SUPPLIERS and answer (a) and (b) parts of this question:Table: STORE
    ItemNo Item Scode Qty Rate LastBuy
    2005 Sharpener Classic 23 60 8 31-Jun-09
    2003 Ball Pen 0.25 22 50 25 01-Feb-10
    2002 Gel Pen Premium 21 150 12 24-Feb-10
    2006 Gel Pen Classic 21 250 20 11-Mar-09
    2001 Eraser Small 22 220 6 19-Jan-09
    2004 Eraser Big 22 110 8 02-Dec-09
    2009 Ball Pen 0.5 21 180 18 03-Nov-09

    Table: SUPPLIERS

    Scode Sname
    21 Premium Stationers
    23 Soft Plastics
    22 Tetra Supply
    1. Write SQL commands for the following statements:
      1. To display details of all the items in the STORE table in ascending order of LastBuy.
      2. To display ItemNo and Item name of those items from STORE table whose Rate is more than 15 Rupees.
      3. To display the details of those items whose supplier code (Scode) is 22 or Quantity in Store (Qty) is more than 110 from the table Store.
      4. To display minimum Rate of items for each supplier individually as per Scode from the table STORE.
    2. Give the output of the following SQL queries:
      1. SELECT COUNT(DISTINCT Scode) FROM STORE;
      2. SELECT Rate* Qty FROM STORE WHERE ItemNo = 2004;
      3. SELECT Item, Sname FROM STORE S, Suppliers P WHERE S.Scode= P.Scode AND ItemNo = 2006;
      4. SELECT MAX(LastBuy) FROM STORE;
  46. Write a program to perform insert and delete operations on a Queue containing Members details as given in the following definition of itemnode :
    MemberNo integer
    MemberName String
    Age integer

    OR

    Determine the total memory consumption by following the sequence.
    List1 = [40,45, “Ekta”]

    1. excluding memory consumption by actual data
    2. including memory consumption by actual data

12 Computer Science Sample Paper -01
Class 12 – Computer Science


Solution

  1. Part-A (Section-I) Attempt any 15 Questions
  2. (c) myWORK
    Explanation: myWORK, String2.upper() will convert all the characters of a string to Upper Case.
  3. None object will be returned, (no return statement).
  4. The rmdir() method deletes an empty directory, which is passed as an argument in the method. Before removing a directory, all the contents in it should be deleted, i.e. directory should be empty. OSError will be raised if the specified path is not an empty directory.
  5. (a) ‘wi’
    Explanation: windows[:2] = ‘wi’
  6. (d) b, c, f
    Explanation:

    • In file path, ‘\r’ is a carriage return character, to normalise it we use another / before it or use ‘r’ prefix before the file path.
    • We do not need to mention the file keyword to input the file path in open function.
  7. The names defined inside a current module can be found by using dir () function.
  8. A Connection (represented through a connection object) is the session between the application program and the database. To do anything with the database, one must have a connection object. For connection Python module PyMySQL is installed properly on your machine.
  9. Module namespace is organized in a hierarchical structure using dot notation.
  10. 0 a 1 b 2 c
  11. The variables that are defined outside every function(local scope) in the program have a global scope. They can be accessed in the whole program anywhere (including inside functions).
  12. When the array is unsorted liner search is used Binary search is performed in a sorted array.
  13. mysql > SELECT SUM (sal), AVG (sal), MAX (sal), MIN (sal) FROM empl;
  14. These are data structures whose elements form a sequence e.g. Stack, queue and linked lists.
  15. (b) ID
    Explanation: ID, A primary key is a key that is unique for each record.
  16. Domain name:  income.in
    URL:  http://www.income.in/home.aboutus.htm
  17. (c) Having
    Explanation: The HAVING clause is closely associated with the GROUP BY clause.
  18. A Database connection is a facility that allows client software to talk to database server software, whether on the same machine or not.
  19. The wildcard character is used to substitute one or more characters in a string. They are used with the LIKE operator to search a value similar to a specific pattern in a column. There are 2 wildcard operators.
    % – represents 0,1 or many characters
    — represents a single number or character.
  20. A repeater is an electronic device that receives a signal, amplifies it and then retransmits it on the network so that the signal can cover longer distances.
  21. MySQLdb is an interface for connecting to a MySQL database server from Python. It implements the Python Database API v2.0 and is built on top of the MySQL  API.
  22. (a) 0000
    Explanation: 0000,  1’s complement arithmetic to get the sum.
  23. Section-II (Case study based Questions)
    1. MIN (AVERAGE)
      63
    2. SUM(STIPEND)
      1000
    3. AVG(STIPEND)
      450
    4. COUNT (distinct SUBJECT)
      4
    5. EXEC sp_rename ‘old_table_name’, ‘new_table_name’
    1. my_file =open(‘poemBTH.txt’, ‘r’) will open the given file in read mode and my_file.read() read the entire file in string form.
    2. my_file = open(‘poemBTH.txt’, ‘r’) will open the given file in read mode and my_file.read(100) read only the first 100 bytes from the file and store the read bytes in form of a string.
    3. +
    4. open(“data.txt”,”r”)
    5. ​​​​​open(“data.txt”,”w”)
  24. Part – B (Section-I)
  25. lis = eval(input (“Enter list:”))
    last = lis[-1]
    for i in range(len(lis) -1, 0, -1):
    lis[i] = lis[i – 1]
    lis[0] = last
    print(lis)
  26. Phishing is fraudulent attempts by cybercriminals to obtain private information. For e.g.a message prompt your personal information by pretending that the bank/mail service provider is updating its website. There are various phishing techniques used by attackers:
    • Embedding a link in an email to redirect to an unsecured website that requests sensitive information
    • Installing a Trojan via a malicious email attachment
    • Spoofing the sender’s address in an email to appear as a reputable source and request sensitive information
    • Attempting to obtain information over the phone by impersonating a known company vendor.

    OR

    1. FM: Frequency Modulation
    2. AM: Amplitude Modulation
    3. NFS: Network File Server
    4. FTP: File Transfer Protocol
  27. An Internet Protocol (IP) address is a numerical identification and logical address that is assigned to devices connected in a computer network. An IP address is used to uniquely identify devices on the internet and so one can quickly know the location of the system in the network.
    In a network, every machine can be identified by a unique IP address associated with it and thus help in providing network security to every system connected in a network.
  28. Fruitful function – The functions that return a value i.e., non-void functions are also known as fruitful functions.
    Non – fruitful function – The functions that do not return a value, i.e., void functions are also known as non-fruitful functions.OROutput of the code is:
    Name a not defined.

    Since, a was declared after its use in myfunc() function a = 2 is declared, after the statement y = a, resulting in the not defined error.

  29. N = int(input(“Enter N: “))
    step = N // abs(N)
    sum = 0
    for i in range(N, 2*N + step, step):
    sum += i
    print(sum)
  30. All variables in a program may not be accessible at all locations in that program. This depends on the location of the declaration of the variable. The scope of a variable determines the region of the program where you can access a particular identifier. If a variable is accessed outside the scope, Python gives an error of “variable_name is not defined”.
    There are two basic scopes of variables in Python :

    1. Global variables that are accessible throughout the program anywhere inside all functions have global scope.
    2. Local variables that are accessible only inside the function where they are declared, have local scope.
  31. The given query is erroneous because it involves pattern matching.
    The correct operator to be used for pattern matching is LIKE. Also, there is NULL comparison and for it also incorrect operator is used. The correct operator for NULL comparison is IS. Thus, the correct SQL statement will be :
    SELECT Name, class FROM students WHERE Stream-name IS NULL OR Stream-name LIKE “%computers” ;
  32. Data types are the classification of data items. Data types represent a kind of value which determines what operations can be performed on that data. Some common data types are Integer, Float, Varchar, Char, String, etc.
    Main objectives of datatypes are:

    1. Optimum usage of storage space
    2. Represent all possible values
    3. Improve data integrity
  33. Degree. The number of columns or attributes or fields in a relation/table is called the table’s degree.
    Cardinality. The number of rows/tuples/record in a relation/table is called the table’s cardinality. For example, for a table shown below :

    BookNo. Name Author Price
    B01 Good learning Xion Z. 220
    B02 Smile easy T. Singh 350
    B03 I to U S. Sandeep 250

    Its degree is 4 (4 columns)
    Cardinality is 3 (3 rows)

  34. v = 3   # v must be defined before being used
    if v < 5:
    for j in range(v):
    print(‘ABC”)   # () missing for print()
    else:  # wrong indentation; else clause can either be for if
    # or for for loop
    print ( “XYZ” )   # () missing for print()
  35. Section- II
  36. This program is used to create a file and store the data in that file:fp1 = open(“phonebook.dat”, ‘w’)
    fp1.write (“Name”)
    fp1.write (” “)
    fp1.wite (“Phone”)
    fp1.write (“\n”)
    while True:
    name = raw_input (“Enter name:”)
    phno = raw_input (“Enter phone no:”)
    fp1.write (name)
    fp1.write (” “)
    fp1.write (“phno”)
    fp1.write (“\n”)
    ch = raw_Input (“Want to enter more=y/n”)
    if ch == ‘N’ OR ch == ‘n’:
    break
    fp1.close()
  37. def stringCompare(str1, str2):
    if str1.length() != str2.length() :
    return False
    else:
    for i in range (str1.length()):
    if str1[i] != str2[i]:
    return False
    else:
    return Truefirst_string = raw_input(“Enter First string:”)
    second_string = raw_input(“Enter Second string:”)
    if stringCompare(first_string, second_string):
    print (“Given Strings are same.”)
    else:
    print (“Given Strings are different.”)OR

    date = input (“Enter date in MMDDYYYY format: “)
    def prettyPrint(date):
    months={1: ‘January’, 2: ‘February’, 3: ‘March’, 4: ‘April’, 5: ‘May’, 6: ‘June’, 7: ‘July’, 8: ‘August’, 9: ‘September’, 10: ‘October’, 11: ‘November’, 12: ‘December’}
    month = months[int(date[:2])]
    day = date[2:4]
    year = date[4:]
    prettyDate = month + ” ” + day + “, ” + year
    print(prettyDate)
    print(prettyPrint(date))

  38. A module in python is a .py file that defines one or more function/classes which you intend to reuse in different codes of your program. To reuse the functions of a given module, we simply need to import the module using the import command.
    A Python package is a collection of python modules under a common namespace created by placing different modules on a directory along with some special files. This feature comes in handy for organizing modules of one type in one place.
  39. Function header def processNumber(x) : in line 1
    Function call processNumber (y) in line 6
    Arguments y in line 6
    Parameters x in line 1
    Function body x = 72
    return x + 3
    in lines 2 and 3
    Main program y = 54
    res = processNumber(y)
    in lines 5 and 6
  40. Section-III
    1. B-TOWN can house the server as it has the maximum no. of computers.
    2. The optical fiber cable is the best for this star topology.
    3. Switch device – connecting all the computers within each location of B_HUB
    4. VoIP- Voice Over Internet Protocol
      1. SELECT * FROM STORE ORDER BY LastBuy;
      2. SELECT ItemNo, Item FROM STORE WHERE Rate > 15;
      3. SELECT * FROM STORE WHERE (Scode = 22 OR Qty > 110);
      4. SELECT Sname, MIN(Rate) FROM STORE, SUPPLIERS WHERE STORE. Scode = SUPPLIERS.Scode GROUP BY Snam
      1. 3
      2. 880
      3. Item Sname
        Gel Pen Classic Premium Stationers
      4. 24-Feb-10
  41. Insert, delete and display operation on queue:-queue: implemented as a list
    front : integer having position of first element in queue
    rear : integer having position of last element in queue
    “””
    def cls():
    print(“\n” * 100)
    def isEmpty( Qu ) :
    if Qu == [ ] :
    return True
    else :
    return Falsedef Enqueue(Qu, item) :
    Qu.append(item)
    if len(Qu) == 1 :
    front = rear =0
    else :
    rear = len(Qu) – 1

    def Dequeue(Qu) :
    if isEmpty(Qu) :
    return “Underflow”
    else :
    item = Qu.pop(0)
    if len(Qu) == 0 : # if it was single-element queue
    front = rear = None
    return item

    def Display(Qu) :
    if isEmpty(Qu) :
    print (“Queue Empty!”)
    elif len(Qu) == 1:
    print(Qu[0], “<== front, rear”)
    else :
    front = 0
    rear = len(Qu) – 1
    print(Qu[front], “<-front”)
    for a in range(l, rear ) :
    print(Qu[a])
    print(Qu[rear], “<-rear”)

    # __main__
    queue = [ ] # initially queue is empty
    front = None
    while True :
    cls()
    print(“QUEUE OPERATIONS BY USING LIST”)
    print(“l. Insert”)
    print(“2. Delete”)
    print(“3. Display “)
    print(“4. Exit”)
    ch = int(input(“Enter your choice (1-5) : ”))
    if ch == 1 :
    print (“For the new member, enter details below:”)
    memberNo = int( input (“Enter member no :”))
    memberName = input (“Enter member name :”)
    age = int(input(“Enter memberJs age : “))
    item = [memberNo, memberName, age]
    Enqueue(queue, item)
    input(“Press Enter to continue…”)
    elif ch == 2 :
    item = Dequeue(queue)
    if item == “Underflow” :
    print (“Underflow! Queue is empty!”)
    else :
    print(“Deleted item is”, item)
    input(“Press Enter to continue…”)
    elif ch == 3 :
    Display(queue)
    input(“Press Enter to continue…”)
    elif ch == 4 :
    break
    else :
    print (“Invalid choice!”)
    input(“Press Enter to continue…”)

    OR

    List1 = [40,40.5, “Ekta”]

    1. list overheads = 26
      Reference pointer size = 4 bytes (on 32 bit implementation)
      Length of the list =3.
      Memory consumption for list = 3
      List overheads + Reference points size x
      length of the list.
      = 36 + 4  3 = 48 bytes.
    2. Memory consumption by data.
      There are 3 values

      1. integer i.e. 40
        memory consumption = 12 bytes
      2. float i.e. 40.5
        memory consumption = 16 bytes
      3. string i.e. “Ekta”
    3. memory consumption = overloads + 1 * string length
      = 21 bytes + 1 * 4
      = 21 + 4 = 25 bytes
      memory consumption by data = 12 + 16 + 25 = 53 bytes
      memory consumption for list l including actual data = 48 + 53 = 101 bytes
X