0% found this document useful (0 votes)
28 views66 pages

C.S MCQ Practice

The document outlines a curriculum for a Computer Science class, detailing various chapters and topics related to Python programming, functions, and database management. It includes a series of questions and assertions designed to test knowledge on Python concepts, such as data types, function definitions, and variable scope. The document serves as a study guide for students preparing for examinations in Computer Science.

Uploaded by

iamanbu0501
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views66 pages

C.S MCQ Practice

The document outlines a curriculum for a Computer Science class, detailing various chapters and topics related to Python programming, functions, and database management. It includes a series of questions and assertions designed to test knowledge on Python concepts, such as data types, function definitions, and variable scope. The document serves as a study guide for students preparing for examinations in Computer Science.

Uploaded by

iamanbu0501
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 66

INDEX

Sr. No. Name of Chapter /Unit Page No.

1 Python Revision Tour 04-09

2 Working with Functions 10-18

3 Exception Handling 19-24

4 Data File Handling 25-31

5 Data Structure 32-40

6 Computer Networks 41-49

Database Management-
7 50-54
Concepts

8 MYSQL - Querying using SQL 55-59

GROUPING RECORD, JOIN IN


9 60-63
SQL

INTERFACE PYTHON WITH


10 64-68
MYSQL
KENDRIYA VIDYALAYA, AFS, SAMANA

NAME: MR JITENDRA SHAKYAWAR POST: PGT COMP.SC


CLASS : XII SUBJECT: COMP. SCI.
UNIT – I TOPIC- Python Revision Tour
……………………………………………………………………………………………………0

1. Python programs are executed by which language processor?


1. Compiler
2. Interpreter
3. Assembler
D. All of the above
2. Which of the statement is correct?
A. Python is not portable and platform independent.
B. Python is portable and platform dependent.
C. Python is portable and platform independent.
D. Python is not portable and platform dependent
3. Which function can be used to display the output in python
A. show()
B. print()
C. display()
D. output()
4. Tick the correct statement to print Hello World.
A. print(hello)(world)
B. Print(“hello world”)
C. Print(hello world)
D. print(“Hello World ”)
5. Which of the following is String literal?
A. “ABC”
B. “123”
C. Both of the above
D. None of the above
6. Python code can run on a variety of platforms, it means Python is a
.......... language.
A. Graphical
B. Cross-platform
C. Independent
D. All of these
7. Python uses a/an .......... to convert source code to object code.
A. Interpreter
B Compiler
C. Combination of Interpreter and compiler
D. Special virtual engine
8. The interpreter is also called ……………………
A. Python Editor
B. Python Kernel
C. Python shell.
D. None of the Above
9. Python interpreter executes ………………………. statement (Command) at a
time.
A. Two
B. Three
C. One
D. All command
10. The process of removing errors from programs is called __
A. Programming
B. Documentation
C. Debugging
D. None of the above
11. IDLE stands for__________
A. Integrated Development Learning
B. Integrated Development Learning Environment
C. Intelligent Development Learning Environment
D. None of the above
12. program written in a high-level language is called ………………
A. Compile code
B. Object code
C. Source code
D. Binary Code
13. Numbers = [ 4, 8, 9, 2.6, 5 ] is a type of which data type in python?
A. List B. Tuple C. Set D. None of these
14. x=3.123, then int (x) will give?
A. 3.1 B. 0 C. 1 D. 3
15. What data type is the object below? L = {1:”One”,2:”Two”}
A. list
B. dictionary
C. array
D. tuple
16. What is the output of the following code? a, b=8/4/2, 8/(4/2) print(a, b)
A. Syntax error
B. 1.0,4.0
C. 4.0,4.0
D. 4,4
17. What is the result after executing the following:
>>>print (20/4 *5+8-10)
A. 1 B. 23 C. 23.0 D. 2
18. Evaluate the following expression and identify the correct answer.
16 // (4 + 2) * 5 + 2**3 * 4
A. 42
B. 46
C. 18
D. 32
19. Assertion: It is interpreted language.
Reason: Python programs are executed by an interpreter.
(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
20. Assertion: Python is portable and platform independent.
Reason: Python program can run on various operating systems and
hardware platforms.
(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
21. Assertion: Python has a rich library of predefined functions.
Reason: Python is helpful in web development.
(A) Both Assertion and reason are true and reason is correct explanation
of assertion. Learning Objective (if Provided) Understanding Evaluation
Application
(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: Python programs are easy to understand.
Reason: Python programs have a clearly defined syntax and relatively
simple structure.
(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.
23. Assertion: Python is case-sensitive.
Reason: Python does not use indentation for blocks and nested blocks.
(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
24. Assertion: Python program is executed line by line.
Reason: Python is compiled language.
(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
25. Variable names can be of any length.
A. True B. False
26. A tuple can only have positive indexing.
A. True B. False
27. Logical operator not has highest precedence among all the logical
operators:
A. True B. False
28. Expression ‘Ab’+2 will result into ‘Ab2’
A. True B. False
29. “is” is a membership operator in python
A. True B. False
30. Following code will produce True as output:
x=10>5>1 and -3<-2<-1
print(x)
A. True B. False
: SOLUTION:
1 B 18 A
2 C 19 A
3 B 20 A
4 D 21 B
5 C 22 A
6 B 23 C
7 A 24 C
8 C 25 A
9 C 26 B
10 C 27 A
11 B 28 B
12 C 29 B
13 A 30 A
14 D
15 C
16 B
17 C
KENDRIYA VIDYALAYA, AFS, SAMANA

NAME: MR JITENDRA SHAKYAWAR POST: PGT COMP.SC


CLASS : XII SUBJECT: COMP. SCI.
UNIT – I TOPIC- Working with Functions
……………………………………………………………………………………………………0

1. Study the following program and select the possible output:


import random
X=random.random()
Y=random.randint(0,4)
print(int(x),”:”,y+int(x))
a) -1:0
b) 1:6
c) 2:4
d) 0:3
2. What will be the output of the following Python code?
def change(one, *two):
print(type(two))
change(1,2,3,4)
a) Integer
b) Tuple
c) Dictionary
d) An exception is thrown
3. If a function doesn’t have a return statement, which of the following does
the function return?
a) int
b) null
c) None
d) An exception is thrown without the return statement
4. What will be the output of the following Python code?

def find(a, **b):


print(type(b))
find('letters', A='1',B='2')
a) String
b) Tuple
c) Dictionary
d) An exception is thrown
5. Which of the following functions header is correct?
a) def study(a=2, b=5, c) :
b) def study(a=2, b, c=5) :
c) def study(a, b=2, c=5):
d) none of the above
6. Find the output of following code:
x=100
def study(x):
global x
x=50
print(“Value of x is :”, x)
a. 100
b. 50
c. Error
d. None of the above
7. A function is said to be___________ if it calls itself
a. Built function
b. Pre-defined function
c. recursive function
d. None of the above
8. The _________ of a variable is the area of a program where it may be
referenced
a. External
b. Global
c. Scope
d. Local
9. A Function that does not have any return value is known as……………….
a. Library function
b. Void function
c. Fruitful function
d. None of the above
10. when large programs are broken down into smaller units known
as………………
a. sub program
b. functions
c. class
d. None of the above
11. The default value for a parameter is defined in function .....................?
a. Definition
b. Return statement
c. Header
d. None of the above
12. Function randint() is available under which module of
python___________?
a. random
b. math
c. statistics
d. None of the above
13. Assertion: The function header ‘def read (a=2, b=5, c):’ is not correct.
Reason: Non default arguments can’t follow default arguments.
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.
14. Assertion: len( ), type( ), int( ), input( ) are the functions that are always
available for use.
Reason: Built in functions are predefined functions that are always
available for use. For using them we don’t need to import any
module.

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)

Assertion: 50 will be the output of above code.


Reason: Because the x used inside the function study( ) is of local scope.

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:

def study (num = 5):


print(num + 5)
Assertion: We can call the above function either by statement ‘study(7)’
or ‘study( )’.
Reason: As the function contains default arguments, it depends on the
caller that the above function can be called with or without the
value.
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
19. Value returning functions should be generally called from inside of an
expression.
a. True
b. False
20. You can call a function only once after defining it.
a. True
b. False
21. User can change the functionality of a built in functions.
a. True
b. False
22. The variable declared outside a function is called a global variable.
a. True
b. False
23. The default valued parameter specified in the function header becomes
optional in the function calling statement.
a. True
b. False
24. Function makes a program more readable and reduces the program size?
a. True
b. False
Tisha is a student of class XII. During examination, she has been assigned
an incomplete python code (shown below). The code shows the variable
scope in a program. Help her in completing the assigned code.
#Definition of fun() function
…. fun(x, y): # Statement-1
………. a # Statement-2
a = 10
x, y = … # Statement-3
b = 20
b = 30
c = 30
print (a, b, x, y) # Statement-4
a, b, x, y = 1, 2, 3,4
………(50, 100) # Statement-5
fun()
print(a, b, x, y) # Statement-6
25. Identify the suitable keyword to access variable a globally for blank space
in the line marked as Statement-2.
a) local
b) global
c) static
d) None of the above
26. Write down the python to swap the values of x and y for the blank space in
the line marked as Statement-3.
a) y, x
b) Y, X
c) swap(x, y)
d) None of the above
27. Mention the output for the line marked as Statement-4.
a) 10 30 100 50
b) 30 10 100 50
c) 100 30 10 50
d) None of the above
28. Identify the missing code for the blank space in the line marked as
Statement-5.
a) fun
b) FUN
c) Fun
d) None of the above
29. Mention the output for the line marked as
Statement-4.
a) 10 4 3 2
b) 10 3 2 4
c) 10 2 3 4
d) None of the above
30. Identify the suitable keyword for blank space in the line marked as
Statement-1.
a) define
b) def
c) DEF
d) Def
SOLUTION:

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

NAME: MR CHAVDA GAURAV POST: PGT COMP.SC


CLASS : XII SUBJECT: COMP. SCI.
UNIT – I TOPIC- Exception Handling
……………………………………………………………………………………………………0
1. Errors resulting out of violation of programming language’s grammar rules
are known as …………………….
(a) Compile time error
(b) Logical error
(c) Runtime error
(d) Exception
2. An unexpected event that occurs during runtime and causes program
disruption, is called ………………………
(a) Compile time error
(b) Logical error
(c) Runtime error
(d) Exception
3. The errors encountered when a user violates the syntax of a programming
language while writing a code are termed as …………………………………………
(a) Compile time error
(b) Logical error
(c) Runtime error
(d) Exception
4. An interrupt or forced disruption that occurs when a program is run or
executed is termed as …………………………………
(a) Compile time error (b) Exception (c) Runtime error (d) Logical error
5. Which of the following keywords are not specific to exception handling?
(a) try (b) except (c) else (d) finally

6 Which block is a mandatory block in exception handling process?


(a) try (b) except (c) finally (d) else

7 Forced exceptions are indicated using which of the following keywords?


(a) try (b) except (c) finally (d) raise
8. ……………………… exception is raised when input() hits an EOF without
reading any data
9. ……………………… exception when a local or global name is not found.

10. ….………………. Exception is raised when an operation is applied to an object


of wrong type.
11. When denominator of a division expression is zero, …………. Exception is
raised.

12. While accessing a dictionary, if the given key is not found, ……………….
exception is raised.

13 The code which might raise an exception is kept in ……………… block.

14 …………………… Exception is raised when the module given with import


statement is not found.

15. …………………… Exception is raised when the result of an arithmetic


operation is too large to be represented.
16. ………………………… Exception is raised when Esc , Del or Ctrl + C is pressed
during program execution and normal program flow gets disturbed.
17 …………….. and ………………. Statement is used when we think that the code
might fail.
18. Exception and error are the same. (True/False)

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)

26. Which statement is/are true about exception handling?


i. There can be try block without catch block but vice versa is not
possible
ii. There is no limit on the number of catch block corresponding to try
block
iii. The object must be created of a specific class of which the error has
occurred otherwise runtime error will occur
iv. To execute a code with each and every run of program, the code is
written in finally block
(a) i and ii, iv
(b) only iii
(c) ii and iv only
(d) only ii

*The following questions contain two statements: Assertion and


Reasoning. Each question has four choices – (i), (ii), (iii), (iv) –
only one of which is correct. In the light of these statements,
choose the most appropriate option.
(i) Both A and R are true and R is the correct explanation of A.
(ii) Both A and R are true but R is not the correct explanation of A.
(iii) A is true but R is false
(iv) A is false but R is true

27 Assertion (A): Exception handling handles all types of errors and


exceptions
Reasoning(R): Exception handling is responsible for handling anomalous
situations during the execution of a program.

28 Assertion (A) : Exception handling code is separate from normal code.


Reasoning (R) : Program logic is different while exception handling code
uses specific keywords to handle exceptions.
29 Assertion (A) : Exception handling code is clear and block based in
Python.
Reasoning (R) :The code where unexpected runtime exception may
occur is separate from the code where the action takes
place when an exception occurs
30 Assertion (A) : No matter what exception occurs, you can always make
sure that some common actions takes place for all types
of exceptions.
Reasoning (R) : The finally block contains the code that must execute.
: ANSWERS:
1. (a) Compile time error
2. (c) Runtime error
3. (a) Compile time error
4. (c) Runtime error
5. (c) else
6. (c) finally
7. (d) raise
8. EOFError
9. NameError
10. TypeError
11. ZeroDivisionError
12. KeyError
13. try
14. ImportError
15. OverflowError
16. KeyboardInterrupt
17. try , except
18. False, Syntax Error / Compile time error are not considered as Exception.
19. False, Only syntax errors can be found during compile time and Runtime errors
occurs only after we run the program.
20. False, there may be logic error in the program, which may produce wrong
output.
21. True, Exceptions are unexpected conditions occurring at run time.
22. True, except block contain the code that should be executed in case of
exception is raised.
23. True
24. True, Exception is raised during runtime only, if any unexpected condition
occurs at run time
25. False, Due to wrong indentation in a program, IndentationError occurs.
26. (a) i , ii and iv
27. (iv) A is false but R is true
28. (i) Both A and R are true and R is the correct explanation of A.
29. (i) Both A and R are true and R is the correct explanation of A.
30. (i) Both A and R are true and R is the correct explanation of A.

******************
KENDRIYA VIDYALAYA, VIRAMGAON

NAME: MR CHAVDA GAURAV POST: PGT COMP.SC


CLASS : XII SUBJECT: COMP. SCI.
UNIT – I TOPIC- Data File Handling
……………………………………………………………………………………………………0
QUESTIONS :
1. To open a file c:\test.txt for reading, we should give the statement:
(a) file1 = open(“c:\test.txt”,”r”)
(b) file1 = open(“c:\\test.txt”,”r”)
(c) file1 = open(file=”c:\test.txt”,”r”)
(d) file1 = open(file=”c:\\s test.txt”,”r”)
2. To open a file c:\ test.txt for writing, we should use the statement:
(a) fobj = open(“c:\test.txt”,”w”)
(b) fobj = open(“c:\\test.txt”,”w”)
(c) fobj = open(file=”c:\test.txt”,”w”)
(d) fobj = open(file=”c:\\test.txt”,”w”)
3. To open a file c:\ test.txt for appending data, we can give the statement:
(a) fobj = open(“c:\\test.txt”,”a”)
(b) fobj = open(“c:\\test.txt”,”rw”)
(c) fobj = open(file=“c:\test.txt”,”w”)
(d) fobj = open(file=“c:\\ test.txt”,”w”)
4. Which of the following statements is/are true?
(a) when we open a file for reading, if the file does not exist, an error
occurs.
(b) when we open a file for writing, if the file does not exist, a new file is
created.
(c) when we open a file for writing, if the file exists, the existing file is
overwritten with the new file.
(d) All of these
5. Identify the error in the following code.
1. f = open ("workfile.txt', 'r+')
2. f.write('0123456789abcdef')
3. f.write('xyz8466')
4. f.close()
5. f.seek (0)
6. f.read()
6. To read the entire contents of the file as a string from a file object fobj, the
command should be:
(a) fobj.read(2)
(b) fobj.read()
(c) fobj.readline()
(d) fobj.readlines()
7. What will be the output of the following snippet?
f=None
for i in range(5):
with open(“data.txt” , ”w”) as f:
if i>2:
break
print(f.closed)
(a)True (b) False (c) None (d) Error
8. To read the next line of the file from a file object fobj, we use :
(a) fobj.read(2) (b) fobj.read()
(c) fobj.readline() (d) fobj.readlines()
9. To read the remaining lines of the file from object fobj, we use:
(a) fobj.read(2) (b) fobj.read()
(c) fobj.readline() (d) fobj.readlines()
10. The readlines() method returns:
(a) String (b) A list of integers
(c) A list of single characters (d) A list of strings
11. Which module is required to use the built-in function dump() ?
(a) math (b) flush (c) pickle (d) unpickle
12. which of the following functions is used to write data in the binary mode?
(a) write (b) output (c) dump (d) send
13. Which is/are the basic I/O (input-output) stream(s) in file ?
(a) Standard Input (b) Standard Output (c) Standard Errors (d) All of these
14. Which of the following is the correct syntax of file object ‘fobj’ to write
sequence data type using writelines() function ?
(a) file.writelines(sequence) (b) fobj.writelines()
(c) fobj.writelines(sequence) (d) fobj.writeline()
15. What would be the data type of variable data in the following statements?
(a) data = f.read() (b) data = f.read(10)
(c) data = f.readline() (d) data = f.readlines()
16. Which of the following is not a valid mode to open a file ?
(a) ab (b) rw (c) r+ (d) w+
17. Which statement is used to change the file position to an offset value from
the start?
(a) fp.seek(offset,0) (b) fp.seek(offset,1)
(c) fp.seek(offset,2) (d) None of these
18. The difference between r+ and w+ modes is expressed as?
(a) No difference
(b) In r+ mode, the pointer is initially placed at the beginning of the file and
the pointer is at the end for w+
(c) In w+ mode, the pointer is initially placed at the beginning of the file
and the pointer is at the end for r+
(d) Depends on the operating system
19. Which of the following modes is used for both writing and reading from a
binary file ?
(a) wb+ (b) w (c) wb (d) w+
20. Which statement is used to retrieve the current position within the file?
(a) fp.seek() (b) fp.tell() (c) fp.loc (d) fp.pos
21. What happens if no arguments are passed to the seek () method?
(a) file position is set to the start of file
(b) file position is set to the end of file
(c) file position remains unchanged
(d) results in an error
22. import pickle
Names = ["First", "second", 'third', 'fourth', 'Fifth']
lst = []
for i in range(-1, -5, -1):
lst.append(Names[i])
with open("test.dat", 'wb') as fout:
pickle.dump(lst, fout)
with open("test.dat", 'rb') as fin:
nlist = pickle.load(fin)
print(nlist)
23. What is the output of following code ?
fh = file ("poem.txt", "r")
size = len(fh.read())
print (fh.read (5))
24. It is necessary to always create the file in the same default folder where
Python has been installed. (True / False)

25. In binary file, there is no delimiter for a line. (True / False)

26. A binary file stores information in ASCII or Unicode characters. (True/False)


* In the following questions, a statement of Assertion (A) is followed by
a statement of Reason (R). Mark the correct choice as:
(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 not the correct explanation of A.
(c) A is true but R is false (or partly true)
(d) A is false (or partly true) but R is true.
27. Assertion: Python is said to have broadly two types of files – binary and text
files, even when there are CSV and TSV files also

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.

29. Assertion : ‘Pickling’ is the process whereby a Python object hierarchy is


converted into a byte-streams.

Reason : A binary file works with byte-streams.

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

NAME: MR CHAVDA GAURAV POST: PGT COMP.SC


CLASS : XII SUBJECT: COMP. SCI.
UNIT – I TOPIC- Data Structure
……………………………………………………………………………………………………0

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

8 Predict the output of the following code: Application

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

9 Predict the output of the following code: Application


def push(stk,num):
stk.append(num)
def pop():
if len(stk)==0:
print(“Underflow”)
else:
stk.pop()
stk=[10,100,-1,2,4]
push(stk,200)
pop()
pop()
pop()
push(stk,4)
print(stk[-1])

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

(A) Pile of clothes in an almirah


(B) Multiple chairs in a vertical pile
(C) Persons buying movie tickets from a counter
(D) Bangles worn on wrist
12 What will the output of the following Python code? result=0 Analysis
numberList=[10,20,30] numberList.append(40) Evaluation
result=result+numberList.pop()
result=result+numberList.pop() print(result)
(A) 40
(B) 70
(C) 30
(D) 10
13 Predict the output of the following Python code. answer=[]; Analysis
answer.append('T') Evaluation
answer.append('A')
answer.append('M') ch=answer.pop()
print(answer)
(A) ['T', 'A']
(B) ['T', 'A', 'M']
(C) ['A']
(D) IndexError: pop from empty list

14 In Python, list is used for implementing a stack and its built-in-


functions___________ and __________ are used for insertion
and deletion, respectively.

(A) Insert, delete


(B) append, pop
(C) append, remove
(D) append, delete
15 In which data type stack is implemented in Python.
A. List
B. Tuple
C. Int
D. Dictionary

ASSERTIONS AND REASONS (16-20)


16 Assertion : The start index of a stack is -1 Understanding
Reason : Stack Data structure can be implemented through
list in Python
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.
17 Assertion: If the size of a stack is 5 and a sixth element is Analysis
inserted, then Underflow happens
Reason: Overflow is a condition which occurs in bounded stack
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.
18 Assertion: A stack has 2 elements in it. If the stack Analysis
undergoes 3 pop operations one after another
then Underflow occurs.
Reason: Underflow is a condition which occurs when deletion
happens on an empty stack.
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.
19 Assertion: if a stack has the following data, then peek function Understanding
will return 4

Reason: Arithmetic expression can be evaluated using stack


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.

20 Assertion: Stack is a linear data structure. Understanding


Knowledge
Reason: A data structure in which elements are organized in a
sequence is called linear data structure.
(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.

CASE STUDY BASED QUESTIONS (21-25)


Venkat loves to play cricket. His teacher has given him an Application
assignment on his favourite sport. He has to write 2 functions and Analysis
AddPlayer(player,runs) and DeletePlayer() to add and remove a
player from a stack which is implemented using a list. Adding a
player to a stack is only possible if the player has secured
more than 50 runs. Venkat needs your help in completing the
code.

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)

26 The peek operation refers to accessing/inspecting the top Understanding


element in the stack
A. True
B. False

27 The insert operation in stack is known as pop Knowledge


A. True
B. False

28 The top operation does not modify the contents of a stack. Analysis
A. True
B. False

29 Stack implementation can be performed using a list in Python Knowledge


A. True
B. False

30 For loop can be used for traversing a stack Understanding


A. True
B. False
: ANSWERS :

Question No Answer Question No Answer Question No Answer


1 C 11 C 21 B
2 D 12 B 22 C
3 D 13 A 23 B
4 B 14 B 24 C
5 C 15 A 25 A
6 A 16 D 26 A
7 D 17 D 27 B
8 A 18 A 28 A
9 D 19 B 29 A
10 D 20 A 30 A
KENDRIYA VIDYALAYA, VV NAGAR

NAME: MR CHAVDA GAURAV POST: PGT COMP.SC


CLASS : XII SUBJECT: COMP. SCI.
UNIT – II TOPIC- Computer Networks
……………………………………………………………………………………………………0
Sl. No Questions
MULTIPLE CHOICE QUESTIONS (1-15)
1 What is a standalone computer?
(A) A computer that is not connected to a network.
(B) A computer that is being used as a server.
(C)A computer that does not have any peripherals attached to it.
(D)A computer that is used by only one person.
2 Network in which every computer is capable of playing the role of a client,
or a server or both at same time is called
(A) peer-to-peer network
(B) Local Area network
(C) dedicated server network
(D) wide area network
3 First computer network was.
(A) NSFNet
(B) FirstNet
(C) ARPANet
(D) Internet
4 Your school has four branches spread across the city. A computer network
created by connecting the computers of all the school branches, is a.
(A)LAN
(B)WAN
(C)MAN
(D)PAN
5 Which is not a component of data communication system?
a) Protocol
b) Message
c) Media
d) Diode
6 Transmission media are usually categorized as
a) Fixed and Unfixed
b) Guided and Unguided
c) Determinate and Indeterminate
d) Metallic and Nonmetallic
7 Which of the following cables carry data signals in the form of light?
a) Coaxial
b) Fiber-optic
c) twisted pair
d) All of the these
8 In a fiber-optic cable, the signal is propagated along the inner core by
a) Reflection
b) Refraction
c) modulation
d) Interference
9 Which of the following represents the fastest data transmission speed?
a) Kbps
b) Bps
c) Gbps
d) Mbps
10 What does HTTPS stand for?
a) Hyper Text Protocol Secure
b) Hypertext Transfer Protocol Secure
c) Hidden Text Transfer Protocol Station
d) Hypertext Transfer Protocol Station

11 What is the full form of TCP/IP?


a) Transfer Control Protocol/ Internet Protocol
b) Transfer Communication Protocol/Internet Protocol
c) Transmission Control Protocol/Internet Protocol
d) Transmission Communication Protocol/Internet Protocol
12 A set of rules that need to be followed by the communicating parties in order
to have successful and reliable data communication is called
A. Syntax
B. Protocols
C. Medium
D. Semantics
13 Which of the following are components of Data Communication?
A. Sender
B. Receiver
C. Protocol
D. All the above
14 In which of the following switching methods, the message is divided into
small packets?
A. Message switching
B. Packet switching
C. Circuit switching
D. None of these
15 The topology in which all nodes are individually connected to a central
connection point:
A. Ring
B. Bus
C. Star
D. Tree
FILL IN THE BLANK (16-20)
16 _______Address is assigned to network cards by manufacturer
a. IP
b. MAC
c. unique
d. domain
17 Microwaves are ___________.
A) omnidirectional
B) bidirectional
C) unidirectional
D) none of the above
18 Unique physical address of each NIC card is called __________.
(A) IP address
(B) MAC address
(C) HOME address
(D) STATIC address
19 A __________ is a network device that amplifies and restores the signals for
long distance communications.
(A) Repeater
(B) Hub
(C) Switch
(D) Router
20 A _________ is a network device that connects dissimilar networks.
(A) Modem
(B) Gateway
(C) Hub
(D) Switch

ASSERTIONS AND REASONS (21-25)

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.

CASE STUDY BASED (26-30)

Vinayak Corporation, an Uttarakhand based IT Training company, is planning


to set up training centres in various cities in next 2 years. Their first campus
is coming up in Kashipur district. At Kashipur campus, they are planning to
have 3 different blocks for App development, Web designing and Movie
Editing. Each block has number of computers, which are required to be
connected in a network for communication, data and resource sharing. As a
network consultant of this company, you have to suggest the best network
related solutions for them for issues/problems raised in question nos. (26)
to (30), keeping in mind the distances between various blocks/locations and
other given parameters.

26 Suggest the most appropriate block/location to house the SERVER in


Kashipur for effective connectivity.
(A) App Development
(B) Movie Editing
(C) Web Designing
(D) None of the above
27 Suggest a device/software to be installed in the Kashipur Campus to take
care of data security.
(A) Modem
(B) Firewall
(C) Repeater
(D) Switch
28 Suggest the best suitable Network topology to economically connect various
blocks within the Kashipur Campus.
(A) Bus
(B) Star
(C) Ring
(D) Mesh
29 Suggest the location(s) for the placement of Switch / Hub.
(A) App Development
(B) Movie Editing
(C) Web Designing
(D) All of the above
30 Suggest the protocol that shall be needed to provide Video Conferencing
solution between Kashipur Campus and Mussoorie Campus.
(A) TELNET
(B) PPP
(C) VoIP
(D) SMTP
ANSWERS:

Question No Answer Question No Answer Question No Answer

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

NAME:DR PARMENDAR MANGAL POST: PGT COMP.SC


CLASS : XII SUBJECT: COMP. SCI.
Unit – III Name of Chapter : Database Management- Concepts
……………………………………………………………………………………………………0

MULTIPLE CHOICE QUESTIONS

Q. 1 The term _____is used to refer to a record in a table.


(a) Attribute (b) Tuple
(c) Field (d) Instance
Q. 2 A relational database consists of a collection of
(a) Tuple (b) Attribute
(c) Relation (d) Keys
Q. 3 Which of the following is not a legal sub-language of SQL?
(a) DDL (b) QAL
(c.) DML (d) TCL
Q. 4. What is the full form of DBMS ?
(a) Data of Binary Management System
(b) Database Management System
(c) Database Management Service
(d) Data Backup Management System
Q. 5. Which type of data can be stored in the database?
(a) Image oriented data
(b) Text, files containing data
(c) Data in the form of audio or video
(d) All of the above
Q.6 The ability to query data, as well as insert, delete, and alter tuples, is offered by
____________
(a) TCL (Transaction Control Language)
(b) DCL (Data Control Language)
(c) DDL (Data Definition Langauge)
(d) DML (Data Manipulation Langauge)
Q.7 Which command is used to remove a relation from an SQL?
(a) Drop table
(b) Delete
(c) Purge
(d) Remove
Q.8 Which of the following is not the utility of DBMS?
(a) Backup
(b) Data Loading
(c) Process Organization
(d) File organization
Q.9 Which of the following is a component of the DBMS?
(a) Data
(b) Data Languages
(c) Data Manager
(d) All of the above
Q.10 Which of the following is the subset of SQL commands used to manipulate
Database Structures, including tables ?
(a) Data Described Language
(b) Data Retrieval Language
(c) Data Manipulation Language
(d) Data Definition Language
Q.11 DML stands for
(a) Data Manageable Language
(b) Domain Manipulation Language
(c) Data Manipulation Language
(d) None of the above
Q. 12 Which is the following not a DDL command ?
(a) CREATE
(b) UPDATE
(c) ALTER
(d) TRUNCATE
Q. 13 Which is the following not a DML command ?
(a) SELECT
(b) UPDATE
(c) DELETE
(d) CREATE
Q. 14 Which is the following considered as DBMS ?
(a) Access
(b) Oracle
(c) SQL Server
(d) All of the above
Q.15 A row is also called ______
(a) Field
(b) Tuple
(c) both a and b
(d) None of the above

FILL IN THE BLANKS


Q.16 A pool of values wherefrom a field can draw values is called ____
Q.17 A raw in a relation is called _______
Q.18 The number of attribute in a relation is called its _______
Q.19 Collection of logically related data tables is called ________
Q.20 A non-key attribute derived from the primary key of some other relation
is called _______

TRUE / FALSE QUESTIONS


Q. 21 The duplication of data is known as data redundancy.
Q.22 A table in a relational database can store empty values.
Q.23 Common attribute of two tables is called a foreign key.
Q.24 The DDL commands are used to define or redefine schema objects.
Q.25 A primary key can store empty values in it.
ASSERTIONS AND REASONS
Directions :
In the following questions, a statement of Assertion (A) is followed by a statement of
Reason (R). Mark the correct choice as:
(a) Both A and R are true and R is the correct explanation of A.
(b) Both A and R are true but R is not the correct explanation of A.
(c) A is true but R is false (or partly true)
(d) A is false (or partly true) but R is true.
Q. 26 Assertion (A). A database is centrally stored data and a DBMS is a system to
manage the database.
Reason(R). DBMS is a database management system, which is a software
managing the databases.
Q. 27 Assertion (A). Data redundancy may lead to data inconsistency.
Reason (R). When redundant data or the multiple copies of data mismatch, it
makes the data inconsistent.
Q. 28 Assertion (A). Data redundancy may lead to may problems.
Reason (R). In RDBMS, data redundancy is 100% removed.
Q. 29 Assertion (A). A primary key is used to uniquely identify the rows in a data
table.
Reason (R). A primary key is a field or attribute which has a unique value for
each row or tuple.
Q. 30 Assertion (A). A data table can have only one primary key.
Reason (R). In a data table, there can be only one attribute/field containing
unique values for each row.
ANSWER KEY
1.Ans : Tuple
2. Ans : Tuple
3. Ans : QAL
4. Ans : Database Management System
5. Ans : All of the above
6. Ans : DML (Data Manipulation Langauge)
7. Ans : Drop table
8. Ans : Process Organization
9. Ans : All of the above
10. Ans : Data Definition Language
11. Ans : Data Manipulation Language
12. Ans : UPDATE
13. Ans : CREATE
14. Ans : All of the above
15. Ans : Tuple
16. Ans : Domain
17. Ans : Tuple
18. Ans : Degree
19. Ans : Database
20. Ans : Foreign key
21. Ans : True
22. Ans : False
23. Ans : False
24. Ans : True
25. Ans : False
26.A
27.A
28.c
29.A
30.C
KENDRIYA VIDYALAYA AFS WADSAR

NAME:DR PARMENDAR MANGAL POST: PGT COMP.SC


CLASS : XII SUBJECT: COMP. SCI.
Unit – III Name of Chapter : MYSQL - Querying using SQL
……………………………………………………………………………………………………0

Q.1 Which of the following is/are the DDL Statement ?


(a) Create (b) Drop (c) Alter (d) All of these [ ]
Q.2 A Table can have __________
(a) Many primary keys and many unique keys.
(b) One primary key and one unique key
(c) One primary key and many unique keys.
(d) Many primary keys and one unique key. [ ]
Q.3 Which of the following types of table constraints will prevent the entry of
duplicate rows?
(a) Unique (b) Distinct (c) Primary Key (d) Null [ ]
Q.4 Consider the following SQL Statement. What type of statement is this ?
INSERT INTO instructor VALUES (10211, ‘SHREYA’ , ‘BIOLOGY’, 69000);
(a) Procedure (b) DML (c) DCL (d) DDL [ ]
Q. 5 Which of the following statements will delete all rows in a table namely
mytable without deleting the table’s structure.
(a) DELETE FROM mytable;’
(b) DELETE TABLE mytable;
(c) DROP TABLE mytable;
(d) None of these. [ ]
Q.6 Which of the following query will drop a column from a table ?
(a) DELETE COLUMN column_name;
(b) DROP COLUMN column_name;
(c) ALTER TABLE table_name DROP COLUMN column_name;
(d) None of these [ ]
Q. 7 Logical operator used in SQL are:
(a) AND, OR, NOT (b) &&, ||, ! (c) $,|,! (d) None of these [ ]
Q. 8 Which of the following requirement can be implemented using a CHECK
constraint?
(a) Student must be greater than 18 years old.
(b) Student must be form a BRICS Country (Brazil, Russia, India, China)
(c) Student’s roll number must exist in another table(say, namely Eligible)
(d) None of these [ ]
Q.9 The statement in SQL which allows to change the definition of a table is
(a) Alter (b) Update (c) Create (d) select
Q.10 The statement in SQL which allows to change the definition of a table is
(a) Alter (b) Update (c) Create (d) select
Q.11 Key to represent relationship between tables is called
(a)Primary key (b) Secondary Key (c) Foreign Key (d) None of these
Q.12 _____ produces the relation that has attributes of R1 and R2
(a) Cartesian product (b) Difference (c) Intersection (d) Product
Q.13 It is better to use files than a DBMS when there are
(a)Stringent real-time requirements.
(b) Multiple users wish to access the data.
(c) Complex relationships among data.
(d) All of the above.

Q.14 The conceptual model is


(a)dependent on hardware.
(b)dependent on software.
(c)dependent on both hardware and software .
(d)independent of both hardware and software.
Q.15 What is a relationship called when it is maintained between two entities?
(a) Unary (b) Binary (c) Ternary (d) Quaternary
Q.16 Which of the following operation is used if we are interested in only
certain columns of a table?
(a) PROJECTION (b) SELECTION (c) UNION (d) JOIN
Q.17 Which of the following is a valid SQL type?
(a) CHARACTER (b) NUMERIC (c) FLOAT (d) All of the above
Q.18 The RDBMS terminology for a row is
(a)tuple (b) relation (c) attribute (d) degree.
Q.19 State whether the following statement is True or False :
In MYSQL, you can write multiple statements in a single line.
Q.20 State whether the following statement is True or False :
In MYSQL, you can change the column name using UPDATE command.
Q.21 State whether the following statement is True or False :
In MYSQL, PRIMARY KEY and UNIQUE KEY both are the same.
Q.22 State whether the following statement is True or False :
By default, the result of an order by clause is always displayed in
ascending order.
Q.23 Fill in the blank :
________ operator checks whether the particular condition record exists
in the table or not.

Q.24 Fill in the blank:


SELECT is a type of _________ SQL command.
Q.25 Which MySQL function is used to get the current date and time?
(a) DATETIME( ) (b) TODAY( ) (c) DATE( ) (d) NOW( )
Q.26 to 30 are Assertion (A) and Reasoning (R) based questions. Mark the
correct choice as :
(a) Both A and R are true and R is the correct explanation of A.
(b) Both A and R are true but R is not correct explanation of A.
(c) A is true but R is false (or partly true).
(d) A is false (or partly true) but R is true.

Q.26 Assertion (A) : There is a difference between a field being empty or


storing NULL value in a field.
Reason (R) : The NULL value is a legal way of signifying that no value
exists in the field.
Q. 27 Assertion (A) : DDL and DML both are part of SQL.
Reason (R) : Both DDL and DML are interchangeable.
Q. 28 Assertion (A) : both WHERE and HAVING clauses are used to specify
conditions.
Reason (R) : Both WHERE and HAVING are interchangeable.
Q.29 Assertion (A) : DDL and DML both are not the same.
Reason (R) : DDL and DML are two subcategories of SQL where DDL
creates the objects and DML manipulates the data.
Q.30 Assertion (A) : both BETWEEN and IN operators can choose from a list
of values.
Reason (R) : The value ranges and a list of values are interpreted in the
some way in SQL.

*******************
Answers

Question No Answer Question No Answer Question No Answer


1 D 11 C 21 FALSE
2 D 12 A 22 TRUE
3 B 13 B 23 EXITS
4 B 14 D 24 DML
5 A 15 B 25 D
6 C 16 A 26 A
7 A 17 D 27 B
8 A 18 A 28 B
9 A 19 TRUE 29 A
10 A 20 FALSE 30 C
KENDRIYA VIDYALAYA HIMMATNAGAR

NAME: SHAILENDRA MAKWANA POST: PGT COMP.SC


CLASS : XII SUBJECT: COMP. SCI.
Unit – III TOPIC- GROUPING RECORD, JOIN IN SQL
……………………………………………………………………………………………………0

1. Which clause is used with "aggregate function?


a) Group by b) Select c) where d) both a and c
2. A ____ is a query that retrieves rows from more than one table or view?
a) Start b) End c) Join d) All of these
3 Aggregate function can be used in the select list or the ___ clause of a select
statement . They cannot be used in a ____ clause?
a) Where , having b) Having, where
c) Group by, having. d) Group by, where
4. A Cartesian product is returned when ?
a) A join condition is omitted.
b) A join condition is invalid.
c) All the rows in the first table are joined to all the rows in second table.
d) All of these.
5. All Aggregate function ignore NULLs except for ____ function?
a) Distinct b) count (*) c) Average d) None of these
6. SQL applies condition on the groups through _____ clause after groups have
been formed ?
a) Group by b) with c) where d) having
7. Which of the following group function ignore NULL values?
a) MAX b) COUNT c) SUM d) All of these
8. Which SQL function is used to count the number of rows in a SQL query?
a) COUNT ( ) b) Number ( ) c) SUM( ) d) COUNT (*)
9. Function count ( ) is an ____ function ?
a) Single row b) Multiple rows c) Aggregate d) None of these
10. Which of the following is not an aggregate function?
a) Avg b) Sum c) With d) Min
11. Which of the following is a SQL aggregate function?
a) Left b) Avg c) Join d)Len
12. The Sum ( ) if used in condition is used with ____ clause ?
a) Group by b) With c) Where d) Having
13. The Where and Having clause can be used interchangeable in SELECT
queries?
a) True b) False c) only in view d) with order by
14. What is the meaning of HAVING clause in select query?
a) To filter out the summary groups.
b) To filter out the column groups.
c) To filter out the row and column values.
d) None of the above.
15.For the HAVING clause which of the following phase is/are ture ?
a) Act EXACTLY like a WHERE clause.
b) Act like a WHERE clause but is used for columns rather than groups.
c) Act like a WHERE clause but is used for groups rather than rows.
d) Act like a WHERE clause but is used for rows rather than columns.
16. Consider the following statement and tell if it Ture for all cases or in specific
cases.
Having clause is processed after the GROUP BY clause and any aggregate
functions.
a) True for all cases
b) False for all cases
c) True when there is no WHERE clause.
d) True only with where clause
17. The following SQL is which type of join:
SELECT CUSTOMER.CUST_ID, ORDER.CUST_ID, NAME, ORDER _ID
FROM CUSTOMER, ORDER
Where CUSTOMER.CUST_ID = ORDER.CUST_ID;
a) Equal-join b) Natural join c) Outer join d) Cartesian product
18.The following SQL is which type of join:
Select customer.cust_id, order.cust_id,name, order_id
From CUSTOMER, ORDER ;
a) Equal-join b) Natural join c) Outer join d) Cartesian Product
19.Which product is returned in a join query having no join condition?
a) Equal-join b) Cartesian product
c) Both (a) and (b) d) none of the mentioned
20.which is a Join condition that contains an equality operator ?
a)Equijoin b) Cartesian Product c) Both a and b d) None of the mentioned.

Fill in the blank:


21. To compare an aggregate value in a condition,______ clause
is used.
22.To create a summary of records based on the common value in a field in
different rows of the table ______ clause is used.
23. In equi join, the join condition joins the two tables using ________
operator
24. The equi join uses ______ operator in the join condition.
25. Aggregate function cannot be used in ______ clause of the select query.

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

NAME: SHAILENDRA MAKWANA POST: PGT COMP.SC


CLASS : XII SUBJECT: COMP. SCI.
UNIT – III TOPIC-INTERFACE PYTHON WITH MYSQL
……………………………………………………………………………………………………0

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

14. Which function of connection is used to check whether connection to mysql


is successfully done or not?
import mysql.connector as msq
con = msq.connect( #Connection String ) # Assuming all parameter
required as passed
if _______________:
print(“Connected!”)
else:
print(“ Error! Not Connected”)
(a) con.connected()
(b) con.isconnected()
(c) con.is_connected()
(d) con.is_connect()
15. Which of the following component act as a container to hold all the data
returned from the query and from there we can fetch data one at a time?
(a) ResultSet (b) Cursor (c) Container (d) Table

16. Identify the correct statement to create cursor:


import mysql.connector as msq
con = msq.connect( #Connection String ) # Assuming all parameter
required as passed
mycursor = _________________
(a) con.cursor() (b) con.create_cursor()
(c) con.open_cursor() (d) con.get_cursor()
17. Which attribute of of cursor is used to get number of records stored in
cursor (Assuming cursor name is mycursor)?
(a) mycursor.count (b) mycursor.row_count
(c) mycursor.records (d) mycursor.rowcount
18. Which of the Symbols are used for passing parameterized query for
execution to cursor?
(a) % (b) { } (c) $ (d) Both a and b
19. Which function is used to fetch n number of records from cursor?
(a) fetch() (b) fetchone() (c) fetchmany() (d) fetchall()
20. Which cursor function is used to send query to connection?
(a) query() (b) execute() (c) run() (d) send()

Fill in the blank:

21. After importing mysql.connector, first of all____ _____ is established using


connect().
22. After establishing database connection, database______ is created so that
the sql query may be executed through it to obtain resultset.
23. The _________ returns how many rows have been fetched to far using
various fetch methods.
24. The running of sql query through database cursor results into all the records
returned in the form of _________.
25. A connectivity package such as________ must be imported before writing
database. connectivity Python code.

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

You might also like