Nothing Special   »   [go: up one dir, main page]

Computer Answer2 Pre-Board

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Class 12 - Computer Science

Sample Paper - (2022-23)

Solution

Section A
1. (b) False

Explanation: False
2. (c) SELECT city, temperature FROM weather ORDER BY temperature;

Explanation: The ORDER BY keyword sorts the records in ascending order by default.
3. (a) fetchtwo( )

Explanation: There is no fetchtwo( ) method .


4. (a) float()

Explanation: The built-in functions min(), max (), divmod(), ord(), any(), all() etc. throw an error when no arguments
are passed to them. However there are some built-in functions like float(), complex() etc. which do not throw an error.
5. (a) 0000

Explanation: 0000,  1’s complement arithmetic to get the sum.


6. (d) writelines( )

Explanation: writelines(sequence) writes a sequence of strings to the file.


7. (b) 5

Explanation: A list is getting added in list l1 which will be counted as one item for the list.

To practice more questions & prepare well for exams, download myCBSEguide App. It provides complete study
material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams. Teachers can use Examin8 App to create similar
papers with their own name and logo.
8. (b) Fixed, variable

Explanation: Char has a specific length which has to be filled by either letters or spaces whereas Varchar changes its
length accordingly .
9. (b) file

Explanation: File is a named entity stored in storage drive that contains stream of data.
10. (a) he

Explanation: str[:2] prints only the values at index 0 and 1 (as 2 is exclusive) of string and hence the answer is “he”.
11. (c) Job scheduling

Explanation: Job scheduling


12. (b) Pickling

Explanation: Pickling
13. (b) Carrier Sense Multiple Access/Collision Avoidance

Explanation: Carrier-sense multiple access with collision avoidance (CSMA/CA) in computer networking, is a network
multiple access method in which carrier sensing is used.
14. (a) shallow copy

Explanation: shallow copy


15. (c) VB Script

Explanation: VB Script and Java Script are examples of client-side scripting languages. Rest all are server-side scripting
languages.
16. (d) Bus

Explanation: Bus
17. (c) A is true but R is false.

Explanation: Series is a one-dimensional labeled array capable of holding any data type (integers, strings, floating-point
numbers, Python objects, etc.). The axis labels are collectively referred to as the index. if data is an array, an index must
be the same length as the data.
18. (b) Both A and R are true but R is not the correct explanation of A.

Explanation: In append mode, python creates a new file with the specified name if no such file exists. It appends the
content to the file if the file already exists with the specified name. In write mode, python creates a new file with the
specified name if no such file exists. It overwrites the existing file.
Section B
19. In a computer network, collision is a specific condition that occurs when two or more nodes on a network transmit data
at the same time. For example, if two computers on an Ethernet network send data at the same moment, the data will
"collide" and not finish transmitting. In case of a collision, the data gets garbled and cannot be read. Also, it may hamper
the overall performance of the network as collisions often lead to more retransmissions which clog the network and
deteriorate the overall performance of the network.
20. [1, 2, 3]

OR

str1 = input("Enter the string:")

final = ""
for i in range (len (str1)):

    if (i% 2==0):

        final = final + str1[i]

print("Modified string is :", final)

21. import MySQLdb

db = MySQLdb.correct('localhost', 'sales','Admin', 'salar345')

cursor = db.cursor()

sql = """UPDATE order-details set

NUMBORD = NUMBORD+5 where QUOTPRIC

<'%d' OR NUMBORD> '%d'"""

check_value = (100, 3)

try:

db.execute, (sql, check_value)

db.commit ()

except:

db.rollback()

db.close()
22. Answer:
i. The connect( ) function can be used to connect with a database from within Python.
ii. No, You need to download separate DB-API for each database you need to access. It defines a standard interface for
Python database access modules.
23. Option (i) and (iv) are possible.
(i) If Value of PICKER is 2 (iv) If Value of PICKER is 3

BLUE BLUEBLUE
PINK PINKPINK
GREEN GREENGREEN

RED REDRED
PICKER can have a maximum value of 3 and a minimum value of 0.

24. d1 = {'A' : 10, 'B' : 20}

d2 = {'C' : 30, 'D' : 40}

d3 = {'E' : 50, 'F' : 60}

d4 = {}

for i in (d1, d2, d3):

    d4.update(i)

print(d4)

OR

i. ho
ii. ‘o’
iii. n Program
iv. IndexError
25. def display_car():

     car_file = open('car.txt','r')

     cars = file.readlines()

     car_file.close()

     for car in cars:

         temp = car.split() #split the values in a line

         mileage = (int)(temp[2])

         if mileage >100 and mileage <= 150:

             print(car)

display_car()

OR

file_obj = open("data.txt", "r")

lines = file_obj.readlines()

lastline = len(lines) - 1

print ("Last line :", lines[lastline]])


Section C
26. Answer:
i. The length of this tuple is 3 because there are just three elements in the given tuple. Because a careful look at the
given tuple yields that tuple t is made up of:

t1 = "a", 1

t2 = t1, "b", "c"

t3 = t2, "d", 2

t = (t3, "e", 3)
ii. i. Item assignment not possible for tuples as tuples are immutable types.
ii. No error.
iii. Error, Item being assigned to an invalid index (index out of range).
iv. Item assignment not possible for strings as strings are immutable types.
27. i. NAME JOINYEAR

Avisha 2009

ii. MIN(JOINYEAR)
2009

iii. AVG(FEE)

31666.666

OR

i. ALTER TABLE ITEM ADD Discount INT;


ii. DDL means ‘Data Definition Language’. It is used to create and modify the structure of database objects in SQL. So,
DDL commands are DROP TABLE, ALTER TABLE.

DML is ‘Data Manipulation Language’ which is used to manipulate data itself.

So, DML commands are INSERT INTO, UPDATE...SET.


28. 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 True

first_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.")


29. def display1():

    count = 0

    file = open('INDIA.TXT', 'r')

    for LINE in file:

        Words = LINE.split()

        for W in Words:

            if W == " India":

                count = count+1

        print(count)

    file.close()
30. The differences between a local variable and a global variable are as given below :
Local Variable Global Variable

1. It is a variable which is declared within a function or within a 1. It is a variable which is declared outside all the
block functions
2. It is accessible only within a function/block in which it is 2. It is accessible throughout the program
declared

3. Local variables are created when the function has started 3. Global variable is created as execution starts
execution and are lost when the function terminates. and is lost when the program ends.
For example, in the following code, x, xCubed are global variables and n and cn are local variables.

def cube(n):

      cn = n * n * n

      return cn

x = 10

xCubed = cube(x)

print(x, "cubed is", xCubed)

OR

Creating functions in programs is very useful. It offers the following advantages:


i. The program is easier to understand. The main block of the program becomes compact as the code of functions is not
part of it, this is easier to read and understand.
ii. Redundant code is in one place, so making changes is easier. Instead of writing code again when we need to use it
more than once, we can write the code in the form of a function and call it more than once. If we later need to change
the code, we change it in one place only. Thus it saves our time also.
iii. Reusable functions can be put in a library in modules. We can store the reusable functions in the form of modules.
These modules can be imported and used when needed in other programs.
iv. You use functions in programming to bundle a set of instructions that you want to use repeatedly because of their
complexity, are better self-contained in a sub-program and called when needed. That means that a function is a piece
of code written to carry out a specified task.
Section D
31. MAX_SIZE = 1000

stack = [0 for i in range(MAX_SIZE)]

top = 0

def isEmpty ( ):

        global top

        return top == 0

def push(x):

       global stack,top

       if top >= MAX_SIZE:

             return

       stack[top]= x

       top += 1

def pop( ):

       global stack,top

       if isEmpty( ):

             return

       else:

              top -= 1

              return stack[top]

string = input( ).split()

for i in string:

      push(i)

while not isEmpty( ):

       x = pop( )

       print (x + x, end = ' ')

               
32. Answer (i) & (ii) OR (iii) & (iv)

i. def Readfile():

    i=open("Employee.dat", "rb+")

    x=i.readline()

    while(x):

        l=x.split(':')

        if (20000>=float(1[2])<=40000):

            print(x)

        x=i.readline()

ii. The above code raises an error as there has been no file object defined/created by the name s2, which is directly used
in line 3. Therefore, the code will not give any output.
iii. import pickle

ingredients = ['cucumber’, 'pumpkin', 'carrot', 'peas']

with open('recipe.dat', 'wb') as fout:

    pickle.dump(ingredients, fout)
iv. file_obj = open("contacts.txt", "r")

line = file.read( )

info = line.split(',')

print ("Name :",info[0], "\n Phone:", info[1])

file_obj.close( )
33. i. SELECT GCODE, Description FROM GARMENT ORDER BY GCODE DESC ;
ii. SELECT * FROM GARMENT WHERE READY DATE BETWEEN '08-DEC-07' AND '16-JUN-08' ;
iii. SELECT AVG(Price) FROM GARMENT WHERE FCODE = 'F03' ;
iv. SELECT FCODE, MAX(Price), MIN(Price) FROM GARMENT GROUP BY FCODE ;

OR

i. SELECT * FROM WATCHES WHERE WATCHNAME LIKE '%TIME';


ii. SELECT WATCHNAME, PRICE FROM WATCH WHERE PRICE BETWEEN 5000 AND 15000;
iii. SELECT SUM (QTY STORE) FROM WATCHES WHERE TYPE LIKE 'Unisex';
iv. SELECT WATCHNAME, QTY SOLD FROM WATCHES W, SALE S WHERE W.WATCHID = S.WATCHID AND
QUARTER = 1;

v. max (price) min(qty_store)

25000 100

vi. quarter sum(qty_sold)


1 15

2 30

3 45
4 15

vii. watchname price type

HighFashion 7000 Unisex

viii. watchname qty_store qty_sold Stock


HighTime 100 25 75

Wave 200 30 170

LifeTime 150 40 110


Golden time 100 10 90
To practice more questions & prepare well for exams, download myCBSEguide App. It provides complete study
material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams. Teachers can use Examin8 App to create similar
papers with their own name and logo.
Section E
34. i. The most suitable place to house the server is in building JAMUNA because it has the maximum number of
computers.
ii. WAN
iii. i. A switch would be needed in all the building, to interconnect the group of cables from the different
computers in each building.
ii. Repeaters may be skipped as per above layout, (because the distance is less than 100 m) however if building
RAVI and building JAMUNA are directly connected, we can place a repeater there as the distance between
these two buildings is more than 100 m.

OR

Optical Fibre
35. i. i. SELECT Acodes, ActivityName FROM ACTIVITY ORDER BY ACode DESC;
ii. SELECT SUM(PrizeMoney) FROM ACTIVITY GROUP BY Stadium;
ii. i. SELECT Name, Acode FROM COACH ORDER BY Acode;
ii. SELECT * FROM ACTIVITY WHERE SchduleDate < '01-Jan-2004' ORDER BY ParticipantsNum;
iii. i. 3
ii. 12-Dec-2003 19-Mar-2004

You might also like