C.S MCQ Practice
C.S MCQ Practice
Database Management-
7 50-54
Concepts
Please choose the correct choice out of the four options given below:
a. Both Assertion and reason are true and reason is the correct explanation
of assertion.
b. Assertion and reason both are true but reason is not the correct
explanation of assertion.
c. Assertion is true, reason is false.
d. Assertion is false, reason is true.
15. Assertion: Every function returns a value if the function does not explicitly
return a value, then it will return ‘Zero’.
Reason: Zero is equivalent to None.
Please choose the correct choice out of the four options given below:
a. Both Assertion and reason are true and reason is the correct explanation
of assertion.
b. Assertion and reason both are true but reason is not the correct
explanation of assertion.
c. Assertion is true, reason is false.
d. Assertion is false, reason is true.
16. Consider the following code:
x = 100
def study( ):
global x
x = 50
print(x)
Please choose the correct choice out of the four options given below:
a. Both Assertion and reason are true and reason is the correct explanation
of assertion.
b. Assertion and reason both are true but reason is not the correct
explanation of assertion.
c. Assertion is true, reason is false.
d. Assertion is false, reason is true.
17. Assertion (A) : Built in function are predefined in the language that are
used directly
Reason (R) : print() and input() are built in functions
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
18. A function code is given as follows:
1 A 16 C
2 B 17 B
3 C 18 A
4 C 19 A
5 C 20 B
6 B 21 B
7 C 22 A
8 C 23 A
9 B 24 A
10 B 25 B
11 C 26 A
12 A 27 A
13 A 28 A
14 A 29 C
15 C 30 B
KENDRIYA VIDYALAYA, VIRAMGAON
12. While accessing a dictionary, if the given key is not found, ……………….
exception is raised.
19. All type of errors can be found during compile time (True/False)
(True/False)
20. A program running properly but producing wrong output is an exception.
(True/False)
21. Unexpected rare condition occurring during runtime which disrupts a
program’s execution is an exception. (True/False)
22. The except block deals with the exception, if it occurs. (True/False)
23. try , except , finally is the correct order of blocks in exception handling
(True/False)
24. An exception may be raised even if the program is syntactically correct.
(True/False)
25. Value Error occurs due to wrong indentation in a program (True/False)
******************
KENDRIYA VIDYALAYA, VIRAMGAON
Reason: The CSV and TSV are types of delimited text only where the
delimiters are common and tab respectively.
28. Assertion: The file modes “r” , “w” , “a” also reveal the type of file these are
being used with.
Reason: The binary file modes have ‘b’ suffix with regular file modes.
30. Assertion : CSV is a file format for data storage which looks like a text file.
Reason : The information is organized with one record on each line and each
field is separated by comma.
: ANSWERS :
1. (b) file1 = open(“c:\\test.txt”,”r”)
2. (b) fobj = open(“c:\\test.txt”,”w”)
3. (a) fobj = open(“c:\\test.txt”,”a”)
4. (d) All of these
5. The lines 5 and 6 will raise the error as no operation can take place in a closed
file-file is closed at line4. Since the file is opened in read as well write mode,
we just need to bring line 4 at the end of the code.
6. (b) fobj.read()
7. (a) True
8. (c) fobj.readline()
9. (d) fobj.readlines()
10. (d) A list of strings
11. (c) pickle
12. (c) dump
13. (d) All of these
14. (c) fobj.writelines(sequence)
15. (a) String type (b) String type (c) String type (d) List type
16. (b) rw
17. (a) fp.seek(offset,0)
18. (b) In r+ mode, the pointer is initially placed at the beginning of the file and
the pointer is at the end for w+
19. (a) wb+
20. (b) fp.tell()
21. (d) results in an error
22. ['Fifth', 'fourth', 'third', 'second']
23. No output
Explanation:- The fh.read() of line 2 will read the entire file content and place
the file pointer at the end of file. For the fh.read (5), it will return nothing as
there are no bytes to be read from EOF thus print() statement prints nothing.
24. False , we can create file in any folder and then write the relative path to that
file, as argument of open() function.
25. True , Binary files doesn’t have lines, and they are simply sequence of bytes.
26. False , Binary files store data in the form of sequence of bytes, that are not
human readable
27. (a)
28. (a)
29. (b)
30. (a)
KENDRIYA VIDYALAYA, VV NAGAR
Sl. Learning
Question
No Objective
MULTIPLE CHOICE QUESTIONS (1-15)
1 What is the process of inserting data into a stack called?
A. Create
B. Insert Knowledge
C. Push
D. Evaluate
2 What is the process of deleting data from a stack called?
A. Drop
B. Delete Knowledge
C. Erase
D. Pop
3 Which pointer is associated with a stack?
A. First
B. Front Knowledge
C. Rear
D. Top
4 Assume a stack has size 4. If a user tries to push a fifth element
to a stack, which of the mentioned condition will arise?
A. Underflow
Understanding
B. Overflow
C. Crash
D. Successful Insertion
5 If a user tries to pop an empty stack, which of the mentioned
condition will arise?
A. Empty data Understanding
B. Overflow
C. Underflow
D. No error
6 Assume a stack Stk implemented as a list. Predict the output
of the following code.
def push_char(ch):
Stk.append(ch)
def display_stk():
strdata=""
if len(Stk)==0:
print("Empty Stack")
else:
for i in Stk:
strdata+=i
print(strdata[::-1])
push_char('c') Analysis
push_char('b')
push_char('s')
push_char('e')
push_char('2')
push_char('0')
push_char('2')
push_char('1')
A. 1202esbc
B. cbse2021
C. 1
D. s
7 Which of these is not an application of stack? Application
A. Parenthesis Balancing program
B. Evaluating Arithmetic Expressions
C. Reversing Data
D. Data Transfer between Process
def insert_data(stk,num):
stk.append(num)
stk=[2,3,4]
insert_data(stk,10)
print(stk)
A. [2,3,4,10]
B. [10,2,3,4]
C. Overflow
D. Underflow
A. 200
B. 100
C. -1
D. 4
10 Stack data structure works on the following principle. Knowledge
(A) LILO
(B) DIFO
(C) FIFO
(D) LIFO
11 Which of the following is not an application of stack in real- Understanding
life. Application
Incomplete code:
#Creating stack Cricket_Stack=[]
def AddPlayer(player,runs): if runs>50:
Cricket_Stack ____ # statement 2
print(Cricket_Stack) def
DeletePlayer():
if len(Cricket_Stack) ==0: print("Empty
Stack,Cant pop") return -1
else:
pop_item=Cricket_Stack[-1] Cricket_Stack
______________ #statement3
return pop_item
getPlayer= _ ("Enter the player name:") # stat. 1
getruns=int(input("Enter the runs scored by player:"))
AddPlayer(getPlayer,getruns)
print(DeletePlayer())
(Based on the data given above, answer Question No. 21 to 25)
21 Which function will be used in statement 1 to get the player Application
name from the user? and Analysis
A. read()
B. input()
C. get()
D. pop()
22 Identify the missing code to complete the statement 2: Application
A. insert(player) and Analysis
B. push(player)
C. append(player)
D. player(append)
23 Identify the missing code to complete the statement 3: Application
A. delete() and Analysis
B. pop()
C. pop(0)
D. append(-1)
24 Assume the current stack position as ['Azhar','Sachin']. If Application
the function AddPlayer() is called with the arguments and Analysis
('Karan',30) what will be the stack data after the function call?
A. ['Azhar','Sachin','Karan']
B. ('Azhar','Sachin','Karan')
C. ['Azhar','Sachin']
D. ('Azhar','Sachin')
25 Assume the current stack position as ['Don','Virat','Jeff']. If the Application
function DeletePlayer() is invoked ,What will be the data in the and Analysis
stack after the function call?
A. ['Don','Virat']
B. ['Virat','Jeff']
C. ['Virat','Jeff']
D. ['Don', 'Virat','Jeff']
TRUE / FALSE QUESTIONS (26-30)
28 The top operation does not modify the contents of a stack. Analysis
A. True
B. False
21 Assertion: Wide Area Network spreads across cities, countries, continents etc.
Reason: Internet is an example of Wide Area Network.
(A) Both Assertion and reason are true and reason is correct explanation of
assertion.
(B) Assertion and reason both are true but reason is not the correct
explanation of assertion.
(C) Assertion is true, reason is false.
(D) Assertion is false, reason is true.
22 Assertion: Microwaves are used for cellular phone, satellite and wireless LAN
communications.
Reason: Microwaves are Bidirectional.
a) Both Assertion and Reason are true and Reason is the correct explanation
of Assertion.
b) Both Assertion and Reason are true but Reason is not the correct
explanation of Assertion.
c) Assertion is true but Reason is false.
d) Both Assertion and Reason are false.
23 Assertion (A): UTP is popular in LAN technology.
Reasons (R): UTP is flexible, affordable and easy to install.
A. BOTH A and R are true and R is the correct explanation of A.
B. Both A and R are true and R is the not the correct explanation of A.
C. A is true but R is false.
D. A is false but R is true.
24 Assertion (A): Optical cables are very cheap and easy to install.
Reason (R): Optical cables are badly affected by the noise interference.
A. Both A and R are true and R is the correct explanation of A.
B. Both A and R are true and R is the not the correct explanation of A.
C. A is true but R is false.
D. Both A and R are false.
25 Assertion: Hub is a broadcast device and Switch is a unicast device.
Reason: Hub repeats the incoming traffic to all connections whereas Switch
sends traffic only to appropriate connections.
(A) Both Assertion and reason are true and reason is correct explanation of
assertion.
(B) Assertion and reason both are true but reason is not the correct
explanation of assertion.
(C) Assertion is true, reason is false.
(D) Assertion is false, reason is true.
1 A 11 C 21 B
2 A 12 B 22 C
3 C 13 D 23 A
4 C 14 B 24 D
5 D 15 C 25 A
6 B 16 B 26 B
7 B 17 C 27 B
8 A 18 B 28 B
9 C 19 A 29 D
10 B 20 B 30 C
KENDRIYA VIDYALAYA AFS WADSAR
*******************
Answers
True/False Questions:
26. Equi join can use any operator for joining two tables.
27. The HAVING and WHERE clauses are interchangeable.
28. The SQL keyword GROUP BY instructs the DBMS to group together those
rows that have same value in a column.
29.The HAVING clause can take any valid SQL function in its conditions.
30.Join can only be created from two tables.
ANSWER KEY
1.(a)
2.(c)
3.(b)
4.(d)
5.(b)
6.(d)
7.(d)
8.(d)
9.(c)
10.(c)
11(b)
12(d)
13(b)
14(a)
15(c)
16(a)
17(a)
18(d)
19(b)
20(a)
21. HAVING
22 GROUP BY
23 =
24 =
25 WHERE
26.F
27F
28T
29F
30.F
KENDRIYA VIDYALAYA, HIMMATNAGAR
1. In order to open a connection with MYSQL database from within Python using
mysql.connection package,____ function is used ?
(a) open ( ) (b) database( ) (c) connect( ) (d) connectdb( )
2. A database______ controls the connection to an actual datadabe, established
from within a python program?
(a) database object (b) connection object (c) fetch object (d) object
3 The set of records retrieved after executing an SQL query over an established
database connection is called ?
(a) table (b) sqlresult (c) result (d) resultset
4.A database _______ is a special control structure that facilities the rows by
the row processing of records in the retrieved resultset. ?
(a) fetch (b) table (c) cursor (d) query
5.Which of the following is not legal method for fetching records from database
from within a python program ?
(a) fetchone( ) (b) fetchwo ( ) (c) fetchall (d)fetchmany( )
6.To fetch one records retrieved you may use <cursor> ______ method.
(a) fetch( ) (b) fetchone ( ) (c)fetchtuple() (d)fetchmany()
7. To fetch All records retrieved you may use <cursor> ______ method.
(a) fetch( ) (b) fetchone ( ) (c)fetchall() (d)fetchmany()
8. To run an SQL query from python program you may use <cursor> method.
(a) query() (b) execute () (c) run() (d) all of these
9. To reflect the changes made in the database permanently, you need to
<connection>._______ method.
(a) done() (b) reflect() (c) commit() (d) final()
10. Which of the following libraries may be used for connecting with a MySQL
database from a Python program?
(a) mysql.connector (b) pymysql (c) mMySQLServer (d)MySQLClient
11. After importing the connection library, first thing you do is: establish MySQL
database.
(a) Cursor (b) setup (c) Resultset (d) connection
12. Identify the name of connector to establish bridge between Python and
MySQL
(a) mysql.connection (b) connector (c) mysql.connect (d)mysql.connector
13. In the following connection string: Identify the elements:
connect(__<<1>>____ = 127.0.0.1, ____<<2>>____ =‟ root‟,
_____<<3>>____ = „admin‟)
(a) <<1>> = User, <<2>> = password, <<3> = host
(b)<<1>> = host, <<2>> = user, <<3> = password
(c)<<1>> = host, <<2>> = password, <<3> = user
(d) <<1>> = IP, <<2>> = user, <<3> = password
True/False Questions:
26.The SQL query upon execution via established database connection returns
the result in multiple chunks.
27.The cursor.rowcount gives the count in the resultset.
28.The cursor.rowcount return how many rows have been so far retrieved
through fetch() methods from the cursor..
29.A DELETE or UPDATE or INSERT query requires commit( ) to reflect the
changes in the database.
30. Unique and Primary key constraints are the same.
ANSWER KEY
1.(C)
2.(B)
3(D)
4(C)
5(B)
6(B)
7(C)
8(B)
9(C)
10(C)
11(D)
12(D)
13(B)
14(B)
15(A)
16(D)
17(D)
18(D)
19(C)
20(B)
21.DATABASE CONNECTION
22 CURSOR
23 CURSOR_ROW COUNT
24 RESLUTSET
25 MYSQL.CONNETOR
26 F
27 F
28 T
29 T
30 F