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

The ST & SC Development Department, Government of Odisha has introduced an innovative

education programme for the students appearing in +2 Science and Commerce examination
pursuing studies in the ST & SC Development Department Schools (EMRS & HSS) to ensure
quality education at +2 level. In this regard it is to mention that an Academic Performance
Monitoring Cell (APMC) has been set up in SCSTRTI to monitor the Training and Capacity
Building of Teachers of SSD Higher Secondary Schools and Ekalavya Model Residential
Schools (EMRS) to enhance quality education for better performance of the students
appearing +2 Science and Commerce examination.
Since March 2020 due to Covid-19 Pandemic Situation, the state government has closed all
the HSS & EMRS and online classes were going on. The CBSE & CHSE Board were unable to
conduct the offline examinations in 2020 and 2021. Since a few months, offline classes are
going on. To combat the situation, the CBSE & CHSE Boards have introduced alternate
comprehensive examination patterns such as 1st and 2nd Term End Examinations and Quarter
End Examinations etc. to be operative from 2021-22 academic session. Accordingly the
Question patterns have completely being changed by both Boards.
To face this situation, the APMC has designed Workbook-Cum-Question Bank with Answers
as per the new direction of the Boards. The best of subject experts have been roped to
formulate self-contained and self-explanatory “Workbook-Cum-Question Bank with
Answers” as per the new pattern of examinations of CHSE & CBSE Boards. They have tried to
make the material as far as activity based and solution based as feasible.
I would like to extend my sincere thanks to Prof. (Dr.) A. B. Ota, Advisor-Cum-Director and
Special Secretary, SCSTRTI. I would also like to thank Dr. S. C. Das, SLPM, APMC and the team of
subject experts for their sincere effort in bringing out the Question Bank in a very short time.
The Workbook-Cum-Question Bank with Answers will cater to the needs of students during
this pandemic situation and will be extremely useful for students of Science and Commerce of
CBSE and CHSE to face the new pattern of examination, as these are designed accordingly.

Ranjana Chopra
Principal Secretary
ST & SC Development Department
Govt. of Odisha
From the Director's Desk …

The ST and SC Development Department, Government of Odisha, has initiated an


innovative effort by setting up an Academic Performance Monitoring Cell (APMC) in Scheduled
Castes and Scheduled Tribes Research and Training Institute (SCSTRTI) to monitor the
Training and Capacity Building of teachers of SSD Higher Secondary Schools and Ekalabya
Model Residential Schools (EMRS) under the administrative control of the ST & SC
Development Department. This innovative program is intended to ensure quality education in
the Higher Secondary Level of the schools of the ST & SC Development Department.
All Ekalabya Model Residential Schools (EMRS) and Higher Secondary Schools (HSS)
are closed since March 2020 due to Covid-19 pandemic situation. As a result, the CBSE Board
was not able to conduct the final examinations in 2021. As an alternative, the CBSE Board has
st nd
decided to conduct 1 & 2 Term End Examinations in December 2021 & April 2022
respectively with new question pattern for both these examinations.
To cope up with this new situation & as per necessities of students, the Academic
Performance Monitoring Cell has designed and prepared Workbook Cum Question Bank with
Answers in Physics, Chemistry, Biology (Botany & Zoology), Mathematics, Computer Science
and English for Class-XII of the Science steam as per the new pattern of examinations being
adopted by CBSE Board.
The best of the subject experts in all subjects of the state have been roped to prepare the
Workbook-Cum-Question Bank with Answers which are self-contained and self-explanatory.
The tireless efforts and futuristic vision of Prof. (Dr.) A. B. Ota, Advisor-cum-Director
and Special Secretary for his guidance in preparation of these books and getting them
published in very short time deserve special mention. He has been a bedrock of strength and
wisdom to this team during the current pandemic as well.
Hope, these Workbooks will help students in developing their knowledge and skills to
comeout successful in the +2 Examinations.
I wish the publication all success.

Smt. Guha Poonam Tapas Kumar, IAS


Director (ST)
ST & SC Development Department
Govt. of Odisha
An innovative education programme has been initiated by setting up an Academic Performance
Monitoring Cell (APMC) in Scheduled Castes and Scheduled Tribes Research and Training
Institute (SCSTRTI) to monitor the Training and Capacity Building of Teachers of SSD Higher
Secondary Schools and Ekalavya Model Residential Schools (EMRS) and to ensure quality
education of students studying at +2 level under the administrative control of the ST & SC
Development Department.
Due to Covid-2019 pandemic situation, all the schools under administrative control of ST & SC
Development Department are closed since March 2020. As a result different Boards were not
able to conduct offline examinations in 2020 and 2021. As an alternative, CBSE Board and CHSE
Board have made comprehensive examination patterns in the form of 1st & 2nd Term End and 3rd
Quarter End examinations respectively to be followed from 2021-22 academic session.
The present situation demands to fullfill the desire of students and designed new pattern of
questions, which will cater to the need of students to face the examinations boldly without any
fear and nervousness. The APMC under the banner of SCSTRTI has taken the initiative to
prepare Workbook-Cum-Question Bank with Answers in Physics, Chemistry, Biology (Botany
& Zoology), Mathematics, Information Technology / Computer Science, English and Odia of
Science stream and Business Mathematics and Statistics, Business Studies and Management,
Accounting, Cost Accountancy, Fundamentals of Management Accounting, Fundamentals of
Entrepreneurship, Banking & Insurance etc. of Commerce stream as per the new pattern of
questions to be adopted in both CBSE and CHSE Boards and prepared books separately.
The subject experts, who are the best in their respective subjects in the state have been roped in
for this exercise. They have given their precious time to make the new pattern of Question Bank
as activity and solution based as per the direction of both CBSE and CHSE Boards.
I hope this material will be extremely useful for the students preparing for the +2 examination
in different subject of Science and Commerce streams.

Prof. (Dr.) A. B. Ota


Advisor-Cum-Director & Special Secretary
SCSTRTI, Govt. of Odisha
CONTENTS
Sl. Unit Topics Page
No. No.

TERM - I

1. Unit-I Computational Thinking and Programming - 2 1-10

2. Functions and Files 11-18

3. Python Revision Tour 19-24

4. Dictionary Topics 25-26

5. Working with Functions 27-34

6. Data File Handling 35-36

7. Case Based Questions 37-49

8. Sample Question Paper Class: XII 50-66

TERM - II

1. Unit- I Computational Thinking and Programming - 2 67-68

Unit - II Computer Networks 69-86

Unit - III Database Management 87-110

Practice Set 111-113

***
UNIT - I
Computational Thinking and Programming - 2
Revision of Python topics covered in Class XI

1. Who developed the Python language? 7. In which year was the Python 3.0
(a) Zim Den version developed?
(b) Guido van Rossum (a) 2008 (b) 2000
(c) NieneStom (c) 2010 (d) 2005
(d) Wick van Rossum
8. Python is a/an ______based language.
2. The developer of python language (a) Compiler
belongs to which country? (b) Interpreter
(a) Netherlands (b) New Zealand (c) Both Compiler and Interpreter
(c) Nizeria (d) New Delhi (d) None of these
3. The Programming language Python
9. What do we use to define a block of
name came from
code in Python language?
(a) Popular BBC comedy show "Monty
(a) Key (b) Brackets
Python's Flying Circus".
(c) Indentation (d) None of these
(b) Popular comedy circus "Python's
Flying Circus". 10. Which character is used in Python to
(c) Comedy serial "Monty Python" make a single line comment?
(d) None of these (a) / (b) //
4. In which year was the Python (c) # (d) !
language developed?
11. Python is ____________.
(a) 1995 (b) 1972
(a) general purpose, dynamic, high-level,
(c) 1981 (d) 1989
and interpreted programming language.
5. In which language is Python written? (b) low-level language
(a) English (b) PHP (c) Both a & b
(c) C language (d) All of the above (d) None of these
6. Which one of the following is the 12. What is the method inside the class in
correct extension of the Python file? python language?
(a) .py (b) .python (a) Object (b) Function
(c) .p (d) None of these (c) Attribute (d) Argument
1
13. Which of the following declarations is 18. Which of the following declarations is
incorrect? incorrect in python language?

(a) _x = 2 (b) Y = 3 (a) xyzp = 500

(c) 2xyz__ = 5 (d) None of these (b) x y z p = 50 60 70 80


(c) x,y,z,p = 500
14. Why does the name of local variables
(d) x_y_z_p = 5000
start with an underscore discouraged?
(a) To identify the variable 19. Which of the following words cannot
be a variable in python language?
(b) It confuses the interpreter
(a) _val (b) val
(c) It indicates a private variable of a class (c) try (d) _try_
(d) None of these
20. Which of the following operators is the
15. Local variables are variables declared correct option for power (ab)?
(a) a ^ b (b) a**b
(a) Outside a function
(c) a ^ ^ b (d) a ^ * b
(b) Inside a function
21. Which of the following precedence
(c) Both a and b
order is correct in Python?
(d) None of these
a. Parentheses, Exponential, Multiplication,
16. Which of the following is not a Division, Addition, Subtraction
keyword in Python language? b. Multiplication, Division, Addition,
Subtraction, Parentheses, Exponential
(a) val (b) raise
c. Division, Multiplication, Addition,
(c) try (d) with
Subtraction, Parentheses, Exponential
17. Which of the following statements is d. Exponential, Parentheses, Multiplication,
correct for variable names in Python Division, Addition, Subtraction
language?
22. Which one of the following has the
a. All variable names must begin with an same precedence level?
underscore.
a. Division, Power, Multiplication,
b. Can be any length Addition and Subtraction

c. The variable name length is a b. Division and Multiplication


maximum of 2. c. Subtraction and Division
d. All of the above d. Power and Division
2
23. Which one of the following has the 29. Study the following program:
highest precedence in the expression? x=1
(a) Division (b) Subtraction while true:
if x % 5 = = 0:
(c) Power (d) Parentheses
break
24. Which of the following functions is a print(x)
built-in function in python language? x+ =1
(a) val() (b) print() What will be the output of this code?
(c) println() (d) None of these (a) error (b) 2 1
(c) 0 3 1 (d) None of these
25. Study the following function:
round(4.876) 30. Which of the following is not used as
loop in Python?
What will be the output of this function?
(a) for loop
(a) 4 (b) 4.5
(b) while loop
(c) 576 (d) 5 (c) do-while loop
(d) None of the above
26. Which of the following is correctly
evaluated for this function? 31. Which of the following is false
pow(x,y,z) regarding loops in Python?
(a) (x**y) / z (b) (x / y) * z (a) Loops are used to perform certain
tasks repeatedly.
(c) (x**y) % z (d) (x / y) / z
(b) While loop is used when multiple
27. Study the following function: statements are to executed repeatedly
until the given condition becomes false.
all([1,1,0,1])
(c) While loop is used when multiple
What will be the output of this function?
statements are to executed repeatedly
(a) false (b) true until the given condition becomes true.
(c) 3 (d) Invalid code (d) for loop can be used to iterate through
the elements of lists.
28. Study the following function: 32. How many times will the loop run?
all([1,1,1,1]) i=2
What will be the output of this function? while(i>0):
i=i-1
(a) false (b) true
(a) 2 (b) 3
(c) 3 (d) Invalid code
(c) 1 (d) 0
3
33. Which one of the following is a valid 38. Which of the following is a valid for
Python if statement: loop in Python?

(a) if a>=2 : (b) if (a >= 2) (a) for(i=0; i < n; i++)


(b) for i in range(0,5):
(c) if (a => 22) (d) if a >= 22
(c) for i in range(0,5)
34. Can we write if/else into one line in (d) for i in range(5)
python? 39. Which of the following sequences
(a) Yes would be generated by the given line
of code?
(b) No
range (5, 0, -2)
(c) if/else not used in python
(a) 5 4 3 2 1 0 -1
(d) None of the above (b) 5 4 3 2 1 0
35. Which statement will check if a is equal (c) 5 3 1
to b? (d) None of the above

(a) if a = b: (b) if a == b: 40. When does the else statement written


(c) if a === c: (d) if a == b after loop executes?
(a) When break statement is executed in
36. Does python have Switch case the loop
statement?
(b) When loop condition becomes false
(a) True (c) Else statement is always executed
(b) False (d) None of the above
(c) Python has switch statement but we
41. What will be the output of the following
cannot use it. code?
(d) None of the above x = "abcd"
for i in range(len(x)):
37. What will be the output of the following
Python code? print(i)

for i in range(0,2,-1): (a) Abcd (b) 0 1 2 3

print("Hello") (c) 1 2 3 4 (d) a b c d

(a) Hello 42. For loop in python is


(a) Entry control loop
(b) Hello Hello
(b) Exit control loop
(c) Hello Hello Hello
(c) Simple loop
(d) None
(d) None of the above
4
43. In which of the following loop in 51. Python string is the collection of the
python, we can check the condition? characters surrounded by
(a) for loop (b) while loop (a) single quotes
(c) do while loop (d) None of the above (b) double quotes

44. It is possible to create a loop using (c) triple quotes


goto statement in python? (d) single quotes, double quotes, or triple
(a) Yes (b) No quotes.
(c) Sometimes (d) None of the above 52. Python strings are also called the
collection of
45. What we put at the last of the loop?
(a) Unicode characters
(a) semicolon (b) colon
(b) binary code
(c) comma (d) None of the above
(c) Both a & b
46. Which of the following is the loop in (d) None of these
python?
(a) for (b) while 53. Indexing of the Python strings starts
from
(c) do while (d) a and b
(a) 0 (b) 1
47. while(0): , how many times a loop run?
(c) 2 (d) None of these
(a) 0 (b) 1
(c) 3 (d) Infinite 54. What will be the output of string
48. while(1==3): , how many times a loop function capitalize()
run ?
(a) Convert the first character to upper
(a) 0 (b) 1 case
(c) 3 (d) Infinite
(b) Convert last character to upper case
49. if -3 will evaluate to true in python (c) Convert all character to upper case
(a) True (b) False
(d) None of these
(c) Can't say (d) None of these
50. What is the output of the following if 55. What will be the output?
statement txt = "I love apples,
a, b = 12, 5
if a + b: apples are my favorite fruit"
print('True') x = txt.count("apples")
else:
print(x)
print('False')
(a) False (b) True (a) 0 (b) 1

(c) Can't say (d) none of these (c) 2 (d) 3

5
56. The string method islower( ) returns 61. The reverse() method reverses
(a) true if all characters in the string are (a) the sorting order of the elements
lower case
(b) the un-order of the elements
(b) false if all characters in the string are
lower case (c) both order & un-order elements

(c) true if some characters in the string are (d) None of these
lower case
62. What will be the output of below
(d) None of these Python code?
57. Which string method removes spaces str1="Information"
at the beginning and at the end of the print(str1[2:8])
string?
(a) format (b) Formation
(a) strip( ) (b) rstrip( )
(c) lstrip( ) (d) None of these (c) Orma (d) ormat

58. isalnum() methods 63. Study the following code:

(a) Returns true, if all characters in the x = ['XX', 'YY']


string are numeric for i in x:
(b) Returns true, if all characters in the i.lower()
string are alphanumeric
print(i)
(c) Returns false, if all characters in the
string are alphanumeric What will be the output of this program?
(d) none of these (a) ['XX', 'YY'] (b) ['xx', 'yy']
(c) [XX, yy] (d) None of these
59. Lists are used to
(a) store multiple items in a single variable 64. Study the following statement:
(b) store single item in a single variable >>>"a"+"bc"
(c) store multiple items in multi variable What will be the output of this statement?
(d) None of these (a) a+bc (b) abc
(c) a bc+ (d) a
60. The append() method appends an
element 65. Study the following code:
(a) to the end of the list >>>"javatpoint"[5:]
(b) to the beginning of the list What will be the output of this code?
(c) to the middle of the list (a) javatpoint (b) java
(d) None of these (c) point (d) None of these
6
66. Study the following statements: 71. What happens when '2' == 2 is
>>> print(ord('h') - ord('z')) executed?
What will be the output of this statement? (a) false
(a) 18 (b) -18 (b) true
(c) 17 (d) -17 (c) ValueError occurs

67. Study the following program: (d) TypeError occurs

i = 1: 72. Study the following statement


while true: z = {"x":0, "y":1}
if i%3 == 0:
Which of the following is the correct
break statement?
print(i)
(a) x dictionary z is created
Which of the following is the correct output
of this program? (b) x and y are the keys of dictionary z

(a) 1 2 3 (b) 3 2 1 (c) 0 and 1 are the values of dictionary z

(c) 1 2 (d) Invalid syntax (d) All of the above

68. Which of the following option is not a 73. pop() method


core data type in the python language? (a) remove the element with the specified
(a) Dictionary (b) Lists key

(c) Class (d) All of the above (b) remove the dictionary
(c) remove element
69. What error will occur when you
execute the following code? (d) none of these

MANGO = APPLE 74. A tuple is a collection which is


(a) NameError (b) SyntaxError (a) ordered and changeable.
(c) TypeError (d) ValueError (b) ordered and unchangeable

70. Which of the following data types is (c) ordered and unchangeable
shown below? (d) None of these
L = [2, 54, 'python', 5] 75. Which function is used to determine
What will be the output of this statement? how many items a tuple has
(a) Dictionary (b) Tuple (a) tlen() (b) len()
(c) List (d) Stack (c) tuplelen() (d) None of these
7
ANSWER KEYS
1. (b) Guido van Rossum 21. (a) Parentheses, Exponential,
Multiplication, Division, Addition,
2. (a) Netherlands
Subtraction
3. (a) Popular BBC comedy show "Monty
22. (b) Division and Multiplication
Python's Flying Circus".
23. (d) Parentheses
4. (d) 1989

5. (c) C language 24. (b) print()

6. (a) .py 25. (d) 5

7. (a) 2008 26. (c) (x**y) % z

8. (b) Interpreter 27. (a) false

9. (c) Indentation 28. (b) true

10. (c) # 29. (a) error

11. (a) general purpose, dynamic, high- Explanation: Syntax error, there should not
level, and interpreted programming be a space between + and =.
language. 30. (c) do-while loop
12. (b) function
31. (b) While loop is used when multiple
13. (c) 2xyz__ = 5 statements are to executed
repeatedly until the given condition
14. (c) It indicates a private variable of
becomes false
a class
32. (a) 2
15. (b) inside a function
33. (a) if a>=2 :
16. (a) val
34. (a) yes
17. (b) Can be any length
Explanation: Yes, we can write if/else in
18. (b) x y z p = 50 60 70 80
one line. For e.g i = 5 if a > 7 else 0. So,
19. (c) _ try option a is correct.

20. (b) a**b 35. (b) if a == b:


8
36. (b) False 50. (b) True

37. (a) Hello Explanation: In Python, any non-zero value


is considered True. So it will evaluate to
38. (b) for i in range(0,5):
true.
39. (c) 531
51. (d) single quotes, double quotes, or
Explanation: The initial value is 5 which is triple quotes.
decreased by 2 till 0 so we get 5, then 2 is
52. (a) Unicode characters.
decreased so we get 3 then the same thing
repeated we get 1 and now when 2 is 53. (a) 0
decreased we get -1 which is less than 0 54. (a) Convert the first character to upper
so we stop and hence we get 5 3 1. So, case
option c is correct.
55. (c) 2
40. (b) When loop condition becomes false
56. (a) true if all characters in the string are
41. (b) 0123 lower case
Explanation: len(x) will give 4 and the loop 57. (a) strip( )
will run for 4 times starting from 0. Hence
58. (b) Returns true, if all characters in the
output will be 0 1 2 3.
string are alphanumeric
42. (a) Entry control loop
59. (a) store multiple items in a single variable
43. (b) while loop
60. (a) to the end of the list
44. (b) No
61. (a) the sorting order of the elements
45. (b) colon
62. (a) format
46. (d) a and b Explanation: Concept of slicing is used in
47. (a) 0 this question. In string slicing, the output is
the substring starting from the first given
48. (a) 0
index position i.e. 2 to one less than the
49. (a) True second given index position i.e. (8-1=7) of
the given string str1. Hence, the output will
Explanation: In Python, any non-zero value
be "format".
or nonempty container is considered
TRUE. So if - 3 will evaluate to true 63. (b) ['xx', 'yy']

9
64. (b) abc 69. (a) NameError
Explanation: In Python, the "+" operator
Explanation: Mango is not defined hence
acts as a concatenation operator between
the name error.
two strings.
65. (c) point 70. (c) List

Explanation: Slice operation is performed Explanation: Any value can be stored in


on the string. the list data type.
66. (b) -18
71. (a) false
Explanation: ASCII value of h is less than
the z. Hence the output of this code is 104- 72. (d) All of the above
122, which is equal to -18. Explanation: All of the above statements
67. (d) Invalid syntax is correct regarding Python code.
Explanation: Invalid syntax, because this
73. (a) remove the element with the
declaration (i = 1:) is wrong.
specified key
68. (c) Class
74. (b) ordered and unchangeable
Explanation: Class is not a core data type
because it is a user-defined data type. 75. (b) len()

10
Functions and Files

1. Which keyword is use for function? 7. In which part of memory does the
system stores the parameter and local
(a) define (b) fun
variables of function call?
(c) def (d) function
(a) heap
2. Which of the following items are (b) stack
present in the function header? (c) Uninitialized data segment
(a) function name (b) parameter list (d) None of the above

(c) return value (d) Both A and B 8. How is a function declared in Python?

3. What is called when a function is (a) def function function_name():


defined inside a class? (d) declare function function_name():
(a) class (b) method (c) deffunction_name():

(c) module (d) None of these (d) declare function_name():

4. If return statement is not used inside 9. Which one of the following is the
the function, the function will return correct way of calling a function?

(a) None (b) 0 (a) function_name()

(c) Null (d) Arbitary value (b) call function_name()


(c) ret function_name()
5. What is a recursive function?
(d) function function_name()
(a) A function that calls other function.
10. You can also create your own functions,
(b) A function which calls itself repeatedly
these functions are called?
(c) Both A and B
(a) built-in functions
(d) None of the above
(b) user-defined functions
6. Which of the following is the use of id() (c) py function
function in python?
(d) None of the above
(a) Id() returns the size of object.
11. Function blocks begin with the
(d) Id() returns the identity of the object.
keyword?
(c) Both A and B (a) define (b) fun
(d) None of the above (c) function (d) def
11
12. The code block within every function 18. Lambda is a function in python?
starts with? (a) True
(a) ; (b) :: (b) False
(c) : (d) % (c) Lambda is a function in python but user
can not use it.
13. A return statement with __________
(d) None of the above
arguments.
(a) No (b) 1 19. What is a variable defined outside a
(c) 2 (d) Any function referred to as?
(a) local variable
14. ________ are the arguments passed to (b) global variable
a function in correct positional order.
(c) static Variable
(a) Required arguments (d) automatic variable
(b) Keyword arguments
20. What is the output of the following
(c) Default arguments program?
(d) Variable-length arguments z = lambda x : x * x
print(z(6))
15. Which of the following will print the pi
(a) 6 (b) 36
value defined in math module?
(c) 0 (d) error
(a) print(pi)
(b) print(math.pi) 21. What is the output of the following
(c) from math import pi program?
print(pi) print (chr(ord(chr(97))))
(d) from math import pi (a) a (b) A

print(math.pi) (c) 97 (d) error

16. Which operator is used in Python to 22. Choose the correct option with
reference to below Python code?
import modules from packages?
def fn(a):
(a) . (b) *
print(a)
(c) -> (d) &
x=90
17. Where is function defined? fn(x)
(a) Module (a) x is the formal argument.
(d) class (b) a is the actual argument.
(c) Another Function (c) fn(x) is the function signature.
(d) All of the above (d) x is the actual argument.
12
23. Which one of the following is incorrect? 28. Which values are used by the functions
(a) The variables used inside function are to communicate information back to
called local variables. the caller?
(a) local (b) global
(b) The local variables of a particular
function can be used inside other (c) return (d) random
functions, but these cannot be used in 29. What is the output of the program
global space. given below?
(d) The variables used outside function are x = 50
called global variables. def func (x) :
(e) In order to change the value of global x=2
variable inside function, keyword global func (x)
is used. print ('x is now', x)
24. Name the statement that sends back a (a) x is now 50 (b) x is now 2
value from a function. (c) x is now 100 (d) Error
(a) print (b) input 30. Fill in the line of code for calculating
(c) return (d) None the factorial of a number:
def fact (num):
25. Functions that do not return any value
if num == 0 :
are known as:
return 1
(a) fruitful functions
else:
(b) void functions return ___________
(c) library functions (a) num*fact(num-1)
(d) user-defined functions (b) (num-1)*(num-2)
(c) num*(num-1)
26. A variable created or defined within a
(d) fact(num)*fact(num-1)
function body is classified as:
(a) local (b) global 31. What is the output of the following ?
def fun (n):
(c) built-in (d) instance
if (n > 100):
27. Which of the following arguments return n - 5
works with implicit values that are return fun (fun (n+11))
used if no value is provided?
print (fun (45))
(a) keyword (b) required (a) 50 (b) 100
(c) variable-length (d) default (c) 74 (d) Infinite loop

13
32. What is the default return value for a 37. Which of the following function calls
function that does not return any value will cause Error while invoking the
explicitly? below function definition?
(a) None (b) int def test(a, b, c, d)
(c) double (d) null
(a) test(1, 2, 3, 4)
33. Which of the following items are (b) test(a = 1, b = 2, c = 3, d = 4)
present in the function header?
(c) test(a = 1, b = 2, c = 3, 4)
(a) function name only
(d) None of these
(b) both function name and parameter list
(c) parameter list only 38. What is a variable defined outside all
(d) return value the functions referred to as?
(a) A static variable
34. Pick one the following statements to
correctly complete the function body (b) A global variable
in the given code snippet. (c) A local variable
def f(number):
(d) An automatic variable
# Missing function body
print(f(5)) 39. What is a variable defined inside a
function referred to as
(a) return "number" (b) print(number)
(c) print("number") (d) return number (a) A static variable
(b) A global variable
35. Which of the following function
(c) A local variable
headers is correct?
(a) def f(a = 1, b): (d) An automatic variable

(b) def f(a = 1, b, c = 2): 40. Carefully observe the code and give
(c) def f(a = 1, b = 1, c = 2): the answer.
(d) def f(a = 1, b = 1, c = 2, d): def function1(a)
a= a + '1'
36. Which of the following function calls
can be used to invoke the below a=a*2
function definition? >>>function1("hello")
def test(a, b, c, d) (a) indentation Error
(a) test(1, 2, 3, 4) (b) cannot perform mathematical
(b) test(a = 1, 2, 3, 4) operation on strings
(c) test(a = 1, b = 2, c = 3, 4) (c) hello2
(d) test(a = 1, b = 2, c = 3, d) (d) hello2hello2
14
41. What is the result of this code? 47. The first line of function definition
defprint_double(x): starts with ____ and end with _____.
print(2 ** x) (a) def , : (b) def , ::
print_double(3) (c) definition , : (d) definition, }
(a) 8 (b) 6
48. Python refers to value being passed
(c) 4 (d) 10
as ______.
42. Which of the given argument types can
(a) arguments (b) parameters
be skipped from a function call?
(c) both A & B (d) None of these
(a) positional arguments
(b) keyword arguments 49. Python refers to value being received
(c) named arguments as _______
(d) default arguments (a) arguments (b) parameters

43. Python function classified into _____ (c) both A & B (d) None of these
categories.
50. Arguments appear in __________ and
(a) 1 (b) 2
parameters appear in ________.
(c) 3 (d) 4
(a) function call statement, function header
44. Which are python function types
(b) function header, function call statement
(a) Built- in function
(b) User defined function (c) both A & B

(c) Functions defined in module (d) None of these

(d) All of these


51. Arguments in python can be one of
45. Functions pre-defined in a particular these value types
modules and can be used when the
(a) literals (b) variables
Corresponding module is
(a) imported (b) exported (c) expression (d) All of the above

(c) return (d) None of these


52. Python supports _____ types of formal
46. Function may or may not have return arguments/parameters.
statement.
(a) 1 (b) 2
(a) true (b) false
(c) 3 (d) 4
(c) can't say (d) None of these
15
53. Which one is a not formal argument? 57. What is tail recursion?
(a) positional arguments (required (a) A recursive function that has two base
arguments) cases
(b) default arguments (b) A function where the recursive functions
(c) keyword (or named arguments) leads to an infinite loop
(d) value arguments (c) A recursive function where the function
54. Functions that return a value are doesn't return anything and just prints
known as: the values
(a) fruitful functions (d) A function where the recursive call is
the last thing executed by the function
(b) void functions
(c) library functions 58. Recursion and iteration are the same
(d) user-defined functions programming approach.
(a) True (b) False
55. Which of these is false about
(c) Can't say (d) None
recursion?
(a) Recursive function can be replaced by 59. What happens if the base condition
a non-recursive function isn't defined in recursive programs?
(b) Recursive functions usually take more (a) Program gets into an infinite loop
memory space than non-recursive (b) Program runs once
function
(c) Program runs n number of times where
(c) Recursive functions run faster than non- n is the argument given to the function
recursive function
(d) An exception is thrown
(d) Recursion makes programs easier to
understand 60. To open a file c:\scores.txt for reading,
we use _________.
56. What will be the output of the following
Python code? (a) infile = open("c:\scores.txt", "r")
(b) infile = open("c:\\scores.txt", "r")
def test(i,j):
(c) infile = open(file = "c:\scores.txt", "r")
if(i==0):
(d) infile = open(file = "c:\\scores.txt", "r")
return j
else: 61. To open a file c:\scores.txt for writing,
return test(i-1,i+j) we use _________.
(a) outfile = open("c:\scores.txt", "w")
print(test(4,7))
(b) outfile = open("c:\\scores.txt", "w")
(a) 13 (b) 7
(c) outfile = open(file = "c:\scores.txt", "w")
(c) Infinite loop (d) 17
(d) outfile = open(file = "c:\\scores.txt", "w")
16
62. To open a file c:\scores.txt for 64. To read the next line of the file from a
appending data, we use _________. file object infile, we use ________.
(a) outfile = open("c:\\scores.txt", "a") (a) infile.read(2)
(b) outfile = open("c:\\scores.txt", "rw") (b) infile.read()
(d) outfile = open(file = "c:\scores.txt", "w") (c) infile.readline()
(d) outfile = open(file = "c:\\scores.txt", "w") (d) infile.readlines()

63. To read two characters from a file 65. The readlines() method returns
object infile, we use _________. ________.
(a) infile.read(2) (a) Str
(b) infile.read() (b) a list of lines
(c) infile.readline() (c) a list of single characters
(d) infile.readlines() (d) a list of integers

ANSWER KEYS
1. (c) def 14. (a) Required arguments

2. (d) Both A and B 15. (c) from math import pi

3. (b) method print(pi)

4. (a) None 16. (a) .

5. (b) A function which calls itself repeatedly 17. (d) All of the above

6. (b) Id() returns the identity of the object. 18. (a) True

7. (b) stack 19. (b) global variable

8. (c) deffunction_name(): 20. (b) 36

9. (a) function_name() 21. (a) a

10. (b) user-defined functions 22. (d) x is the actual argument.

11. (d) def 23. (b) The local variables of a particular


function can be used inside other
12. (c) :
functions, but these cannot be used
13. (a) No in global space

17
24. (c) return 46. (a) true

25. (b) void functions 47. (a) def , :

26. (a) local 48. (a) arguments

27. (d) default 49. (b) parameters

28. (c) return 50. (a) function call statement, function


header
29. (a) x is now 50
51. (d) All of the above
30. (a) num*fact (num-1)
52. (c) 3
31. (b) 100
53. (d) value arguments
32. (a) None
54. (a) fruitful functions
33. (a) both function name and parameter list
55. (c) Recursive functions run faster than
34. (d) return number
non-recursive function
35. (c) def f(a = 1, b = 1, c = 2):
56. (d) 17
36. (a) test(1, 2, 3, 4)
57. (d) A function where the recursive call is
37. (c) test(a = 1, b = 2, c = 3, 4) the last thing executed by the function

38. (b) A global variable 58. (b) False

39. (c) A local variable 59. (a) Program gets into an infinite loop

40. (a) indentation Error 60. (b) infile = open("c:\\scores.txt", "r")

41. (a) 8 61. (b) outfile = open("c:\\scores.txt", "w")

42. (d) default arguments 62. (a) outfile = open("c:\\scores.txt", "a")

43. (c) 3 63. (a) infile.read(2)

44. (d) All of these 64. (c) infile.readline()

45. (a) imported 65. (b) a list of lines

18
Chapter : 1
Python Revision Tour

1. Python identifiers are case sensitive. 7. Which of the following literals must
(a) True terminate in one line?
(b) False (a) Single line Strings
(c) Depends on Program (b) Multi line strings
(d) Depends on the computer system (c) Numeric Literals
(d) All of the above
2. Which of the following is an invalid
identifier ? 8. To include non-graphic characters in
(a) CS_class_XII python, which of the following is used?
(b) csclass12 (a) Special Literals
(c) _csclass12 (b) Boolean Literals
(d) 12CS (c) Escape Character Sequence
(d) Special Literal - None
3. The tiny individual unit in python
program is known as _______. 9. The octal literal and hexadecimal
(a) Expression (b) Statement literals start with which of the following
(c) Token (d) Comment symbols respectively?
(a) O0 and X0 (b) 0O and 0X
4. Which of the following not a token? (c) Oct0 and Hex0 (d) 0o and 0x
(a) Comments (b) Identifiers
(c) Literals (d) Operators 10. Which of the following literal has either
True or False value?
5. Which of the following are pre-defined (a) Special Literals
or reserved words that convey a
special meaning in programming (b) Boolean Literals
language? (c) Numeric Literals
(a) Identifiers (b) Literals (d) String Literals
(c) Keywords (d) Operators
11. Which of the following are symbols
6. The different names given to different used for computation or logical
parts of a program is known as ______. comparison in a program?
(a) Identifiers (b) Literals (a) Identifiers (b) Literals
(c) Keywords (d) Operators (c) Keywords (d) Operators
19
12. Which of the following is correct 18. ___ are additional readable information
statement to computer square of to clarify the statement in python.
variable x in python? (a) Comments (b) Expressions
(a) x * 2 (b) x power 2 (c) Tokens (d) Flow of control
(c) x ** 2 (d) x // 2
19. Which of the following is a group of
13. If you want to display the values without statements which are part of another
decimal place after division, which of statement or functions?
the following symbol is used? (a) Expression (b) Statement
(a) / (b) // (c) Block (d) Comment
(c) % (d) ** 20. All statements inside a block are
14. Which of the following is a correct intended at same level.
statement? (a) True

(a) xyz = 10 100 1000 (b) False


(c) Not necessarily
(b) x y z = 10 100 1000
(d) Depends on user's choice
(c) x, y, z = 10, 100, 1000
(d) x y z= 10, 100, 1000 21. By default the input() function returns
(a) Integer (b) Float
15. Which of the following are symbols
used in programming languages to (c) Boolean (d) String
organize statement structures and 22. If a function does not return a value
inidicate the rythm of the program? then what value will be returned by
(a) Operators (b) Punctuators python in a function?
(c) Functions (d) Literals (a) int (b) void

16. In python, the single line comments (c) bool (d) none
starts with _______. 23. The output of d= a + b % c is ________,
(a) / (b) // if a = 12, b=5 and c=3.
(c) # (d) "' (a) 14 (b) 2

17. In python, the multiline comments (c) 5 (d) 17


starts with ________ 24. Evaluate x % y // x, if x = 5, y = 4
(a) / (b) // (a) 1.0 (b) 0.0
(c) # (d) "' (c) 0 (d) 1
20
25. Which of these arithmetic operators 31. What is the output of - "5" + "5"?
will evaluate first?
(a) 25 (b) 55
(a) + (b) -
(c) 10 (d) Error
(c) ** (d) %
32. If n="Hello" and user wants to assign
26. Which of the following logical operator
n[0]='F' what will be the result?
will evaluate first?
(a) and (b) or (a) It will replace the first character

(c) not (d) is not (b) It's not allowed in Python to assign a
value to individual character using
27. How a>b>c will be interpreted by python?
index
(a) a>b or a>c (b) a>b not a>c
(c) It will replace the entire word Hello
(c) a>b and a>c (d) a>b && a>c
into F
28. Which of the following statement is (d) It will remove H and keep rest of the
correct for and operator? characters
(a) Python only evaluates the second
argument if the first one is False 33. Which of the following operator can be
(b) Python only evaluates the second used as replication operator?
argument if the first one is True (a) + (b) *
(c) Python only evaluates True if any one (c) ** (d) /
argument is True
(d) Python only evaluates False if any one 34. Which point can be considered as
argument is False difference between string and list?

29. Which of the following forces an (a) Length


expression to be converted into (b) Indexing and Slicing
specific type? (c) Mutability
(a) implicit type casting (d) Accessing individual elements
(b) mutable type casting
(c) immutable type casting 35. In list slicing, the start and stop can be
given beyond limits. If it is then
(d) explicit type casting
(a) raise exception IndexError
30. ___________ are stored as individual
characters in contiguous locations, (b) raise exception ValueError
with two-way index for each location. (c) return elements falling between
(a) lists (b) tuples specified start and stop values
(c) strings (d) dictionaries (d) return the entire list
21
36. In list slicing negative index-1 refers to (c) deletes 1st and 3rd element from
(a) first element the list
(b) last element (d) deletes 1st, 2nd and 3rd element from
(c) second last element the list

(d) second element 42. If l=[11,22,33,44], then output of


37. Which of the following operator cannot print(len(l)) will be
used with strings? (a) 4 (b) 3
(a) == (b) +
(c) 8 (d) 6
(c) * (d) /
43. Which of the following method is used
38. Ms. Hetvee is working on a string
to delete element from the list?
program. She wants to display last four
characters of a string object named s. (a) del() (b) delete()
Which of the following is statement is
(c) pop() (d) All of these
true?
(a) s[4:] (b) s[:4] 44. What will be the output of following
(c) s[-4:] (d) s[:-4] code:

txt="Term 1"
39. The append() method adds an element at
print(txt*2)
(a) first (b) last
(c) specified index (d) at any location (a) Term 1 Term 2 (b) Term 1Term 1

(c) Term 1 2 (d) TTeerrmm 11


40. Which of the following statement is
true for extend() list method?
45. What will be the output of:
(a) ads element at last
txt="SQP2021"
(b) ads multiple elements at last if txt.isalnum()==True:
(c) ads element at specified index print("Term 1 sample paper is out now")
(d) ads elements at random index else:
41. The statement del l[1:3] do which of the print("Term 1 sample paper is not out till now")
following task?
(a) Term 1 sample paper is not out till now
(a) deletes elements 2 to 4 elements from
(b) Term 1 sample paper is out now
the list
(b) deletes 2nd and 3rd element from (c) SQP2021
the list (d) Error
22
46. What will be the output of the following 51. What will be the output of the following
statement given: code:
txt="term 1. sample paper 2021" t=(4,5,6)
print(txt.capitalize()) t1=t*2
(a) term 1. sample paper 2021 print(t1)
(b) Term 1. Sample Saper 2021
(a) (4,5,6,4,5,6) (b) (4,4,5,5,6,6)
(c) Term 1. sample paper 2021
(c) (8,10,12) (d) None of the above
(d) Term 1. Sample Paper 2021
47. Which of the following statement 52. What will be the output of :
prints output as 'B'? t=(4,5,6)
(a) char(66) (b) ord('B') del t[1]
(c) char(66) (d) chr(66) print(t)

48. Which of the following statement(s) is/ (a) (4,6) (b) ([4,6])
are correct? (c) [4,6] (d) Error
(a) Tuples can have only integer elements.
53. Which of the following operation is
(b) Tuples can have only string elements. supported in python with respect to
(c) Tuples can have various types of tuple t?
elements. (a) t[1]=33 (b) t.append(33)
(d) Tuples can either integer or string, but (c) t=t+t (d) t.sum()
not both at once.
54. Which of the following statements
49. Which of the following statement prints the output (4,5)?
creates a tuple? (a) print(t[:-1]) , print(t[0:2])
(a) t=[1,,2,3,4] (b) t={1,2,3,4} (b) print(t[3]), print(t[:-3])
(c) t=<1,2,3,4> (d) t=(1,2,3,4) (c) print(t[2:3]), print(3:2)
(d) print(t[0,2]), print[2,3]
50. Which of the following statement is
correct? 55. What will be the output of the following
code:
(a) Tuples are mutable.
t=(4,5,6,7,8,9,3,2,1)
(b) Tuples are immutable.
print(t[5:-1])
(c) Tuples and lists are same. (a) (8,9,3,2,1) (b) (9,3,2)
(d) All of these are correct. (c) (4,5,6,7) (d) (2,3,9)

23
ANSWER KEYS
1. (a) True 29. (d) explicit type casting
2. (d) 12CS 30. (c) strings
3. (c) Token 31. (b) 55
4. (a) Comments 32. (b) It's not allowed in Python to assign a
5. (c) Keywords value to individual character using index
6. (a) Identifiers 33. (b) *
7. (a) Single line Strings 34. (c) Mutability
8. (a) Escape Character Sequence 35. (c) return elements falling between
9. (a) 0o and 0x specified start and stop values
10. (b) Boolean Literals 36. (b) last element
11. (d) Operators
37. (d) /
12. (c) x ** 2
38. (c) s[-4:]
13. (c) %
39. (b) last
14. (c) x, y, z = 10, 100, 1000
40. (b) ads multiple elements at last
15. (b) Punctuators
41. (b) deletes 2nd and 3rd element from
16. (c) #
the list
17. (c) #
42. (a) 4
Note:Python does not really have syntax for
43. (c) pop()
multiline comments. To add a multiline
44. (b) Term 1Term 1
comment you could insert a # for each line
45. (b) Term 1 sample paper is out now
18. (a) Comments
46. (c) Term 1. sample paper 2021
19. (c) Block
20. (a) True 47. (d) chr(66)

21. (d) String 48. (c) Tuples can have various types of
22. (d) none elements.
23. (a) 14 49. (d) t=(1,2,3,4)
24. (c) 0 50. (b) Tuples are immutable.
25. (c) ** 51. (a) (4,5,6,4,5,6)
26. (c) not 52. (d) Error
27. (c) a>b and a>c 53. (c) t=t+t
28. (b) Python only evaluates the second 54. (a) print(t[:-1]) , print(t[0:2])
argument if the first one is True 55. (b) (9,3,2)

24
Dictionary Topics

1. Dictionaries are also known as _____. 5. Which one of the following is the
(a) mappings correct statement for creating a
dictionary for assigning a day number
(b) hashes
to weekdays using short names?
(c) associative arrays
(a) d ={1:Mon,2:Tue,3:Wed,4:Thur}
(d) all of the above
(b) d ={1:'Mon',2:'Tue',3:'Wed',4:'Thur'}
2. Dictionaries are ______ type of python.
(c) d ={1;'Mon',2;'Tue',3;'Wed',4;'Thur'}
(a) Mutable
(d) d ={1-'Mon',2-'Tue',3-'Wed',4-'Thur'}
(b) Immutable
6. Om is learning the concept of dictionary
(c) simple
in python. He read something about a
(d) Complex
dictionary related to a set of elements.
3. Mr. Subodh is working with a dictionary But he forgot the term which type of
in python for his project. He wants to set of elements, suggest from the
display the key, value pair but confuse below-given options:
out of these statements, choose the
(a) sorted (b) ordered
correct statement for him:
(c) unordered (d) random
(a) dict.values()

(b) disct.keys() 7. Eshika is trying to delete an element


from the dictionary, but she is getting
(c) dict.keysvalues()
an error - "the given key is not found
(d) dict.items()
in the dictionary". Which of the
4. The fromkeys() method assigns _____ following command she has used in
value to key in dictionary by default. the python

(a) 0 (a) del dict[key]


(b) None (b) dict.pop(key)
(c) Empty (c) dict.popitem(key)
(d) Blank (d) remove dict[key]

25
8. Which of the following is the correct 11. Marks in the above-created dictionary
statement for checking the presence are changed after rechecking, where
of a key in the dictionary? Vishwa got 48 marks and Mayank got
(a) <key> in <dictionary_object> 49 marks. Choose the correct
(b) <key> not in <dictionary_object> statement for the same:
(c) <key> found in <dictionary_object> (a) dict.change({'Vishva':48,'Mayank':49})
(d) <key> exists in <dictionary_object>
(b) dict.alter({'Vishva':48,'Mayank':49})
9. What will be the output of the following (c) dict.update({'Vishva':48,'Mayank':49})
dictionary?
(d) dict.loc({'Vishva':48,'Mayank':49})
d={'South Africa':'Faf Du Plesis','India':
'ViratKohli','Pakistan':'BabarAzam',' 12. What happens when the following
Australia':'Steve Smith'} statement will be written for the same
print(d['ViratKohli']) dictionary created in Que. No. 10?

(a) India (b) India-ViratKohli dict.update({'Sameer':44})


(c) ViratKohli (d) KeyError (a) It will raise an error - KeyError

10. Predict the correct output for the (b) It will add a new key and value at the
following code: end of the dictionary

dict={'Manthan':34,'Vishwa':45,'Mayank':50} (c) It will replace the last key and value with
the given key and value
print(dict[0])
(a) Manthan:34 (b) 34 (d) It will add a new key and value at the
beginning of the dictionary
(c) Manthan (d) Error

ANSWER KEYS
1. (d) all of the above 7. (a) del dict[key]

2. (a) Mutable 8. (a) <key> in <dictionary_object>

3. (d) dict.items() 9. (d) KeyError

4. (b) None 10. (d) Error

5. (b) d ={1:'Mon',2:'Tue',3:'Wed',4:'Thur' 11. (c) dict.update({'Vishva':48,'Mayank':49})

12. (b) It will add a new key and value at the


6. (c) unordered
end of the dictionary
26
Working with Functions

1. Aman wants to write a function in 7. Read the statements:


python. But he doesn't know how to Statement (A) : A function can perform
start with it! Select the keyword used certain functionality
to start a function out of the following: Statement (B) : A function must return a
(a) function (b) start result value
(c) def (d) fun (a) Statement A is correct

2. Which of the following is a valid (b) Statement B is correct


function name? (c) Statement A is correct but Statement
(a) start_game() (b) start game() B is not correct

(c) start-game() (d) All of the above (d) Both are incorrect

3. Which of the following is not a part of 8. Richa is working with a program where
the python function? she gave some values to the function.
She doesn't know the term to relate
(a) function header (b) return statement
these values. Help her by selecting the
(c) parameter list (d) function keyword correct option.
4. If the return statement is not used in (a) function value
the function then which type of value (b) arguments or parameters
will be returned by the function? (c) return values
(a) int (b) str (d) function call
(c) float (d) None
9. Mohini wants to know that the symbol :
5. The function header contains (colon) must be required with which of
(a) function name and parameters only the following function part?
(b) def keyword along with function name (a) function header
and parameters (b) function body
(c) return statement only (c) return statement
(d) parameter list only (d) parameters

6. The subprogram that acts on data 10. Which of the function part contains the
and returns the value sometimes is instructions for the tasks to be done
known as in the function?
(a) Function (b) Module (a) function header (d) function body
(c) Class (d) Package (c) return statement (d) parameters
27
11. Ananya is trying to understand the 15. Which of the following sentence is not
features of python functions. She is not correct for the python function?

understanding the feature that (a) Python function must have arguments

distributes the work in small parts. (b) Python function can take an unlimited
number of arguments
Select the appropriate term for her out
(c) Python function can return multiple
of the following:
values
(a) Modularity (b) Reusability (d) To return value you need to write the
(c) Simplicity (d) Abstraction return statement
16. Pranjal wants to write a function to
12. Which of the following is not a feature compute the square of a given number.
supported by python functions But he missed one statement in the
function. Select the statement for the
(a) Modularity (b) Reusability
following code:
(c) Simplicity (d) Data Hiding defsq(n):
____________
13. Divya wants to print the identity of the print(sq(3))
object used in the function. Which of (a) return square of n
the following function is used to print (b) return n**2
the same? (c) return n
(a) identity() (b) ide() (d) print("n**n")

(c) id() (d) idy() 17. Select the proper order of execution
for the following code:
14. Rashmin is learning the python
(A) def diff(a,b):
functions He read the topic types of
(B) c=a-b
python functions. He read that
(C) print("The Difference is :",c)
functions already available in the
python library is called ___________. (D) x,y =7,3
(E) diff(x,y)
Fill appropriate word in this blank :
(F) print("Finished")
(a) UDF (User Defined Function)
(a) A -> B -> C -> D -> E -> F
(b) Built-in Functions (b) D -> E -> F -> A -> B -> C
(c) Modules (c) D -> E -> A -> B -> C -> F

(d) Reusable Function (d) E -> B -> C -> D -> A -> F

28
18. What is the maximum and minimum 22. Archi is confused between arguments
value of c in the following code snippet? and parameters. Select the fact about
argument and parameter and solve
import random
her doubt
a = random.randint(3,5)
(a) arguments are those values being
b = random.randint(2,3) passed and parameters are those
c=a+b values received

print(c) (b) parameters are those values being


passed and arguments are those
(a) 3 , 5 (b) 5, 8
values received
(c) 2, 3 (d) 3, 3
c) arguments appear in the function
19. By default python names the segment header and parameters appear in the
with top-level statement as ________. function call

(a) def main() (b) main() d) arguments can have same name and
parameters can have value type
(c) __main__ (d) _main
23. The value is passed through a function
20. The order of executing statements in
call statement is called _________ and
a function is called
the values being received in the
(a) flow of execution definition is known as __________.

(b) order of execution (a) formal parameter, actual parameter

(c) sequence of execution (b) actual parameter, formal parameter

(d) process of execution (c) passed parameter, received parameter

21. In python function, the function calling (d) value parameter, constant parameter

another function is known as ____and 24. The positional parameters are also
the function being called is known ___. known as
(a) main, keyword (a) required arguments
(b) caller, called (b) mandatory arguments
(c) called, caller (c) Both a and b
(d) executer, execute (d) None of them

29
25. Which of the following is true about the 29. What will be the output of the following
default argument code?
(a) default values are provided in the def fun(x=10, y=20):
function call
x+=5
b) default values are provided in the
y=y-3
function body
c) default values are provided with the return x*y
return statement print(fun(5),fun())
d) default values are provided in the (a) 20, 200
function header
(b) 170, 255
26. The default valued parameter specified
in the function header becomes (c) 85, 200
optional in the function calling
(d) 300, 500
statement.
(a) Yes (b) No 30. What will be the output of the following
(c) Not Sure (d) May be code?
v = 80
27. Which of the following function header
is correct : def display(n):

(a) def discount(rate=7,qty,dis=5) global v


(b) def discount(rate=7,qty,dis) v = 15
(c) def discount(rate,qty,dis=5) if n%4==0:
(d) def discount(qty,rate=7,dis) v += n

28. Read the following statements and else:


then select the answer: v -= n
Statement A: Default arguments can be print(v, end="#")
used to add new parameters to the existing display(20)
functions
print(v)
Statement B: Default arguments can be
used to combine similar functions into one (a) 80#80
(a) Statement A is correct
(b) 80#100
(b) Statement B is correct
(c) 80#35
(c) Both are correct
(d) Both are incorrect (d) 80#20
30
31. Observe the following lines written for 33. What will be the output of the following
the calling statement and select the code:
appropriate answer: defor_cap_update(pl,r,i):
ele_bill(past_reading=200,rate=6,current_reading=345) pl['Runs']+=r
ele_bill(current_reading=345,rate=6,past_reading=200) pl['Innings']+=i
ele_bill(rate=6,past_reading=200,current_reading=345) pl1={'S.No':1,'Name':'K
(a) all lines have errors L Rahul','Runs':528,'Innings':12}

(b) Only line 1 will execute and the rest will pl2={'S.No':2,'Name':
raise an error 'Rituraj Gaikwad','Runs':521,'Innings':13}
or_cap_update(pl1,35,1)
(c) All lines are correct and no errors
or_cap_update(pl2,35,1)
(d) only line 3 is correct
print(pl1)
32. What will be the output of the print(pl2)
following?
(a) {'S.No': 1, 'Name': 'K L Rahul', 'Runs':
def Val(m,n): 35, 'Innings': 1}
for i in range(n): {'S.No': 2, 'Name': 'RiturajGaikwad',
'Runs': 35, 'Innings': 1}
if m[i]<30:
(b) {'S.No': 1, 'Name': 'K L Rahul', 'Runs':
m[i]//=5
563, 'Innings': 13}
elif m[i]%5 == 0: {'S.No': 2, 'Name': 'RiturajGaikwad',
m[i]//=3 'Runs': 556, 'Innings': 14}

else: (c) {'S.No': 1, 'Name': 'K L Rahul', 'Runs':

m[i]//=2 528, 'Innings': 12}


{'S.No': 2, 'Name': 'RiturajGaikwad',
l = [25,8,75,12]
'Runs': 521, 'Innings': 13}
Val(l,4)
(d) {'S.No': 1, 'Name': 'K L Rahul', 'Runs':
for i in l: 528, 'Innings': 1}
print(i,end="$") {'S.No': 2, 'Name': 'RiturajGaikwad',
'Runs': 521, 'Innings': 1}
(a) 1$1$2$25$2$
34. Which of the following variable is
(b) 5$1$25$2$
defined outside the function?
(c) 1$4$25$3$ (a) local (b) global
(d) 5$2$15$2$ (c) enclosed (d) All of these

31
ANSWER KEYS
1. (c) def 20. (a) flow of execution
2. (a) start_game() 21. (b) caller, called
3. (d) function keyword 22. a) arguments are those values being
4. (d) None passed and parameters are those
values received
5. (b) def keyword along with function
name and parameters 23. b) actual parameter, formal parameter

6. (a) Function 24. c) Both a and b

7. (c) Statement A is correct but Statement 25. d) default values are provided in the
B is not correct function header
8. (b) arguments of parameters 26. a) Yes
9. (a) function header 27. c) def discount(rate,qty,dis=5)
10. (b) function body 28. c) Both are correct
11. (a) Modularity 29. b) 170, 255
12. (d) Data Hiding 30. c) 80#35
13. (c) id() 31. c) All lines are correct and no errors
14. (b) Built-in functions 32. (b) 5$1$25$2$
15. (a) Python function must have arguments
33. (b) {'S.No': 1, 'Name': 'K L Rahul', 'Runs':
16. (b) return n**2 563, 'Innings': 13}
17. (c) D -> E-> -> A -> B -> C -> F {'S.No': 2, 'Name': 'RiturajGaikwad',
18. (b) 5,8 'Runs': 556, 'Innings': 14}

19. (c) __main__ 34. (b) global

32
Function Case Study based Questions

Observe the following code and select 39. In the line #Line4 the multiply(l) is
appropriate answers for the given questions: called __________
total = 1 (a) caller (b) called

def multiply(l):#Line 1 (c) parameter (d) argument

for x in l: 40. In function header multiply(l), l refers


_______ total #Line2 to ____________
total *= x (a) caller (b) called

return _______ #Line3 - Reutrn variable (c) parameter (d) argument

l=[2,3,4] 41. In function calling multiply(l), l refers


print(multiply(_____),end="") # Line4 to___________
print(" , Thank you ") (a) caller (b) called
(c) parameter (d) argument
35. Identify the part of function in #Line1?
42. What will be the output of this code?
(a) Function header
(a) 2 3 4 , Thank you
(b) Function Calling
(b) 234 , Thank You
(c) Return statement
(c) 24 , Thank you
(d) Default Argument
(d) Thank You
36. Which of the keyword is used to fill in 43. Which of the following statement
the blank for #Line2 to run the program indicates the correct statement for the
without error? formal parameter passing technique?
(a) eval (b) def (a) multiply(l)
(c) global (d) return (b) multiply(l=[23,45,66])
(c) multiply([23,45,66])
37. Which variable is going to be returned
(d) multiply(23,45,66)
in #Line3
(a) total (b) x 44. Which of the following statement
indicates the correct statement for the
(c) l (d) None
actual parameter passing technique?
38. Which variable is required in the (a) multiply(l)
#Line4? (b) multiply(l=[23,45,66])
(a) total (b) x (c) multiply([23,45,66])
(c) l (d) None (d) multiply(23,45,66)

33
45. Sonal wants to modify the function
ANSWER KEYS
with the specification of length of list
with default argument statement for
the function with the list and 10 35. (a) Function Header
elements by default. Which of the 36. (c) global
following statement is correct?
37. (a) total
(a) def multiply(n=10,l):
38. (c) l
(b) def multiply(l,n=10):
39. (a) caller
(c) def multiply(l,10):

(d) defmyultiply(l=[22,34,56,22,33,12,45,66,7,1]) 40. (b) argument

41. (c) parameter


46. Diya wants to call the function with
default argument value in the function 42. (d) 24, Thank You
to display the product of list tobject l.
43. (a) multiply(l)
Select the correc statement for her to
the same. 44. (c) multiply([23,45,66])

(a) multiply(l) (b) multiply(10) 45. b) def multiply(l,n=10)

(c) multiply(l,n) (d) multiply(n,l) 46. a) multiply(l)

34
Data File Handling
1. A ___________ is a bunch of bytes 7. Which of the following statement is not
stored on some storage devices like correct for text file?
hard-disk, pen-drive etc. (A) Contains the information as same as
(a) Folder (b) File its held in memory
(c) Package (d) Library (B) No delimiter for a line
(C) Read and write faster than binary files
2. The ____________ are the files that
store data pertaining to a specific (D) Common format for general work
application, for later use. (a) A and B only (b) A, B and C
(a) Data File (b) Program File (c) A, C and D (d) All of them
(c) Source Code (d) Program Code
8. A basic approach to share large data
3. Which of the following format of files among different organizations carried
can be created programmatically out through
through python program? (a) text files
(a) Data Files (b) Video Files (b) binary files
(c) Media Files (d) Binary Files (c) spreadsheets or database

4. Supriya doesn't know about text file (d) email attachments


extension. Help her to identify the
9. The CSV files can be accessed by
same out of these:
(a) text editor and spreadsheet software
(a) .text (b) .txt
(b) only through python programs
(c) .txf (d) .tfx
(c) Only spreadsheet software
5. In python which of the following is
(d) Only through database software
default EOL character?
(a) \eol (b) \enter 10. Each line in CSV file is known as
(c) \n (d) \newline (a) tuple (b) data/record
(c) field (d) format
6. Which of the following statement is
correct for binary files? 11. Read the statements and choose the
(a) The file content returned to user in correct answer:
raw form Statement A: It is very difficult to organize
(b) Every line needs translation unstructured data
Statement B: CSV helps into organize
(c) Each line is terminated by EOL
huge amount of data in proper and
(d) It stores ASCII or Unicode characters systematic way
35
(a) Only Statement A is correct 14. The default directory for the performing
the most of the functions is known as
(b) Only Statement B is correct
(a) active directory
(c) A and B both are correct
(b) current directory
(d) None of them is correct
(c) working directory
12. Which of the following are features of (d) open directory
CSV files:
15. Biswajit wants to working with files
(a) easy to read and manage and directories through python. Select
(b) smaill in size the python module to help him to do
finish his work:
(c) fast to process data
a) os b) csv
(d) All of them
c) pickle d) sys
13. While opening a file for any operation
16. Manoj wants to get the name of the
python looking for current directory. Select appropriate
(a) File in the system folder statement for the same:

(b) file in the python installation folder (a) os.getcd()


(b) os.getcurrentdirectory()
(c) file in the current folder where the .py
file is saved (c) os.getcwd()

(d) file in downloads folder (d) os.currentdirectory()

ANSWER KEYS
1. (b) File 9. (a) text editor and spreadsheet software
2. (a) Data File 10. (b) data/record
3. (d) Binary Files 11. (c) A and B both are correct
4. (b) .txt 12. (d) All of them
5. (c) \n 13. (c) file in the current folder where the .py
6. (a) The file content returned to user in raw file is saved
form 14. (b) current directory
7. (d) All of them 15. (a) os
8. (c) spreadsheets or database 16. (c) os.getcwd()

36
CASE BASED QUESTIONS

1. Rohit, a student of class 12th, is learning i. Identify the suitable code for blank
CSV File Module in Python. During space in line marked as Statement-1.
examination, he has been assigned an (a) csv file (b) CSV
incomplete python code (shown below) to
(c) csv (d) Csv
create a CSV File 'Student.csv' (content
shown below). Help him in completing the ii. Identify the missing code for blank
code which creates the desired CSV File. space in line marked as Statement-2?
CSV File (a) "School.csv","w"
1,AKSHAY,XII,A (b) "Student.csv","w"
2,ABHISHEK,XII,A (c) "Student.csv","r"
3,ARVIND,XII,A
(d) "School.csv","r"
4,RAVI,XII,A
iii. Choose the function name (with
5,ASHISH,XII,A
argument) that should be used in the
Incomplete Code
blank space of line marked as
import #Statement-1 Statement-3
fh = open( , , newline='') #Statement-2 (a) reader(fh) (b) reader(MyFile)
stuwriter = csv. #Statement-3
(c) writer(fh) (d) writer(MyFile)
data = []
header = ['ROLL_NO', 'NAME', 'CLASS', iv. Identify the suitable code for blank
space in line marked as Statement-4.
'SECTION']
data.append(header) (a) 'ROLL_NO', 'NAME', 'CLASS', 'SECTION'

for i in range(5): (b) ROLL_NO, NAME, CLASS, SECTION


roll_no = int(input("Enter Roll Number : ")) (c) 'roll_no','name','Class','section'
name = input("Enter Name : ") (d) roll_no,name,Class,sectionc) co.connect()
Class = input("Enter Class : ")
v. Choose the function name that should
section = input("Enter Section : ")
be used in the blank space of line
rec = [ _______ ] #Statement-4 marked as Statement-5 to create the
data.append(rec) desired CSV File?
stuwriter. (data) #Statement-5 (a) dump() (b) load()
fh.close() (c) writerows() (d) writerow()
37
2. Amritya Seth is a programmer, who has __________ #2 statement to write the list
recently been given a task to write a python L into the file
code to perform the following binary file Choice = input("enter more (y/n): ")
operations with the help of two user defined
if Choice in "nN":
functions/modules:
break
a. AddStudents() to create a binary file
called STUDENT.DAT containing student F.close()
information - roll number, name and marks def GetStudents():
(out of 100) of each student.
Total=0
b. GetStudents() to display the name and
Countrec=0
percentage of those students who have a
percentage greater than 75. In case there Countabove75=0
is no student having percentage > 75 the with open("STUDENT.DAT","rb") as F:
function displays an appropriate message. while True:
The function should also display the
try:
average percent.
_______ #3 statement to read
He has succeeded in writing partial code
and has missed out certain statements, so from the file
he has left certain queries in comment Countrec+=1 Total+=R[2] if R[2] > 75:
lines. You as an expert of Python have to
print(R[1], " has percent =
provide the missing statements and other
related queries based on the following ",R[2])
code of Amritya. Countabove75+=1
Answer any four questions (out of five) from except:
the below mentioned questions.
break
import pickle
if Countabove75==0:
def AddStudents():
print("There is no student who has
_______ #1 statement to open the binary percentage more than 75")
file to write data
average=Total/Countrec
while True:
print("average percent of class =
Rno = int(input("Rno :"))
",average)
Name = input("Name : ")
AddStudents()
Percent = float(input("Percent :"))
GetStudents()
L = [Rno, Name, Percent]
38
i. Which of the following commands is (b) 'w+' opens a file for both writing and
used to open the file "STUDENT.DAT" reading. Adds at the end of the existing
for writing only in binary format? file if it exists and creates a new one if
(marked as #1 in the Python code) it does not exist.

(a) F= open("STUDENT.DAT",'wb') (c) 'wb' opens a file for reading and writing

(b) F= open("STUDENT.DAT",'w') in binary format. Overwrites the file if it


exists and creates a new one if it does
(c) F= open("STUDENT.DAT",'wb+')
not exist.
(d) F= open("STUDENT.DAT",'w+')
(d) 'a' opens a file for appending. The file
ii. Which of the following commands is pointer is at the start of the file if the file
used to write the list L into the binary exists.
file, STUDENT.DAT? (marked as #2 in v. Which of the following statements
the Python code) correctly explain the function of seek()
(a) pickle.write(L,f) method?

(b) pickle.write(f, L) (a) tells the current position within the file.

(c) pickle.dump(L,F) (b) determines if you can move the file


position or not.
(d) f=pickle.dump(L)
(c) indicates that the next read or write
iii. Which of the following commands is occurs from that position in a file.
used to read each record from the
(d) moves the current file position to a
binary file STUDENT.DAT? (marked as
given specified position
#3 in the Python code)
3. Krrishnav is looking for his dream job but
(a) R = pickle.load(F)
has some restrictions. He loves Delhi and
(b) pickle.read(r,f)
would take a job there if he is paid over
(c) r= pickle.read(f)
Rs.40,000 a month. He hates Chennai and
(d) pickle.load(r,f) demands at least Rs. 1,00,000 to work
iv. Which of the following statement(s) are there. In any another location he is willing
correct regarding the file access modes? to work for Rs. 60,000 a month. The
(a) 'r+' opens a file for both reading and following code shows his basic strategy for
writing. File object points to its beginning. evaluating a job offer.
39
Code: iii. Input- location = "Any Other City", pay = 1
pay = (a) Statement 1 (b) Statement 2
location= (c) Statement 4 (d) Statement 6
if location == "Mumbai":
iv. Input location = "Delhi", pay = 500000
print ("I'll take it!") #Statement 1
(a) Statement 6 (b) Statement 5
elif location == "Chennai":
(c) Statement 4 (d) Statement 3
if pay < 100000:

print ("No way") #Statement 2 v. Input-location="Lucknow", pay=65000

else: (a) Statement 2 (b) Statement 3


print("I am willing!") #Statement 3 (c) Statement 4 (d) Statement 5
elif location == "Delhi" and pay > 40000:
4. Consider the following code and answer
print("I am happy to join") #Statement 4
the questions that follow: Book={1:'Thriller',
elif pay > 60000: 2:'Mystery', 3:'Crime', 4:'Children Stories'}
print("I accept the offer") #Statement 5
Library ={'5':'Madras Diaries','6':'Malgudi
else: Days'}
print("No thanks,I can find something
i. Ramesh needs to change the title in
better") #Statement 6
the dictionary book from 'Crime' to
On the basis of the above code, choose
'Crime Thriller'. He has written the
the right statement which will be executed
following command:
when different inputs for pay and location
are given. Book['Crime']='Crime Thriller'

i. Input: location="Chennai", pay=50000 But he is not getting the answer. Help him
choose the correct command:
(a) Statement 1 (b) Statement 2

(c) Statement 3 (d) Statement 4 (a) Book[2]='Crime Thriller'

(b) Book[3]='Crime Thriller'


ii. Input: location = "Surat" ,pay = 50000

(a) Statement 2 (b) Statement 4 (c) Book[2]=('Crime Thriller')

(c) Statement 5 (d) Statement 6 (d) Book[3] =('Crime Thriller')

40
ii. The command to merge the dictionary v. With reference to the above declared
Book with Library the command would dictionaries, predict the output of the
be: following code fragments

(a) d=Book+Library Code 1 Code 2


Library=Book Library=Book.copy()
(b) print(Book+Library)
Library.pop(2) Library.pop(2)
(c) Book.update(Library)
print(Library) print(Library)
(d) Library.update(Book)
print(Book) print(Book)
iii. What will be the output of the following
line of code: print(list(Library)) (a) Code 1
(a) ['5','Madras Diaries','6','Malgudi Days'] {1: 'Thriller', 2: 'Mystery', 3: 'Crime', 4: 'Children Stories'}

(b) ('5','Madras Diaries','6','Malgudi Days') {1: 'Thriller', 2: 'Mystery', 3: 'Crime', 4: 'Children Stories'}

(c) ['Madras Diaries','Malgudi Days'] Code 2


(d) ['5','6'] {1: 'Thriller', 3: 'Crime', 4: 'Children Stories'}
{1: 'Thriller', 3: 'Crime', 4: 'Children Stories'}
iv. In order to check whether the key 2 is
(b) Code 1
present in the dictionary Book,
Ramesh uses the following command: {2:'Mystery'}
{1: 'Thriller', 2: 'Mystery', 3: 'Crime', 4: 'Children Stories'}
2 in Book
Code 2
He gets the answer 'True'. Now to check
{1: 'Thriller', 3: 'Crime', 4: 'Children Stories'}
whether the name 'Madras Diaries' exists
in the dictionary Library, he uses the {1: 'Thriller', 3: 'Crime', 4: 'Children Stories'}
following command: (c) Code 1
'Madras Diaries' in Library {1: 'Thriller', 3:'Crime', 4: 'Children Stories'}

But he gets the answer as 'False'. Select {1: 'Thriller', 3: 'Crime', 4: 'Children Stories'}
the correct reason for this: Code 2
(a) We cannot use the in function with {1: 'Thriller', 3:'Crime', 4: 'Children Stories'}
values. It can be used with keys only. {1: 'Thriller', 2:'Mystery', 3: 'Crime', 4:'Children Stories'}

(b) W e must use the function (d) Code 1


Library.values() along with the in {1: 'Thriller', 3:'Crime', 4: 'Children Stories'}
operator {1: 'Thriller', 2: 'Mystery', 3: 'Crime', 4: 'Children Stories'}
(c) We can use the Library.items() function Code 2
instead of the in operator {1: 'Thriller', 3:'Crime', 4: 'Children Stories'}
(d) Both b and c above are correct. {1: 'Thriller', 3: 'Crime', 4: 'Children Stories'}

41
5. In a Database, there are two tables with the instances given below:

Table: STUDENTS

ADMNO NAME CLASS SEC RNO ADDRESS PHONE


1211 MEENA 12A D 4 A-26 3245678
1212 VANI 10A D 1 B-25 5456789
1213 MEENA 12B A 1 NULL NULL
1214 KARISH 10B B 3 AB-234 4567890

Table: SPORTS

ADMNO GAME COACHNAME GRADE


1215 CRICKET MR. RAVI A
1213 VOLLEYBALL MR. AMANDEEP B
1211 VOLLEYBALL MR. GOVARDHAN A
1212 BASKET BALL MR TEWARI B

i. Choose the command to display name and game of those students whose address is
available in students' table.
(a) SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE STUDENTS.ADMNO=
SPORTS.ADMNO AND ADDRESS IS NOT NULL;
(b) SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE STUDENTS.ADMNO=
SPORTS.ADMNO AND ADDRESS IS NULL;
(c) SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE STUDENTS.ADMNO=
SPORTS.ADMNO, ADDRESS IS NULL;
(d) SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE STUDENTS.ADMNO=
SPORTS.ADMNO NOT ADDRESS IS NULL;
ii. Identify the statement to delete a column phone from the table students.
(a) ALTER TABLE STUDENTS DROP PHONE;
(b) DROP PHONE;
(c) UPDATE DROP PHONE;
(d) DELETE FROM STUDENTS WHERE DROP PHONE;

42
iii. Choose the command to display Name of the students who are studying in class 12
and their corresponding Coach names

(a) SELECT NAME, COACHNAME FROM STUDENTS, SPORTS WHERE CLASS LIKE
"12%" AND STUDENTS.ADMNO =SPORTS.ADMNO;

(b) SELECT NAME, COACHNAME FROM STUDENTS, SPORTS WHERE CLASS LIKE
"12%" AND STUDENTS.ADMNO= SPORTS.ADMNO;

(c) SELECT NAME, COACHNAME FROM STUDENTS, SPORTS WHERE CLASS LIKE
"12%" AND ADMNO.STUDENTS =ADMNO.SPORTS;

(d) SELECT NAME, COACHNAME FROM STUDENTS, SPORTS WHERE CLASS LIKE=
"12%" AND STUDENTS.ADMNO =SPORTS.ADMNO;

iv. Which two select queries will give the same output

(A) SELECT NAME, GRADE FROM STUDENTS,SPORTS WHERE ADDRESS IS NULL AND
STUDENTS.ADMNO =SPORTS.ADMNO ;

(B) SELECT NAME, GRADE FROM STUDENTS,SPORTS WHERE ADDRESS IS NOT NULL
AND STUDENTS.ADMNO =SPORTS.ADMNO ;

(C) SELECT NAME, GRADE FROM STUDENTS,SPORTS WHERE ADDRESS IS NULL OR


STUDENTS.ADMNO=SPORTS.ADMNO ;

(D) SELECT ST.NAME, SP.GRADE FROM STUDENTS ST,SPORTS SP WHERE ADDRESS


IS NULL AND ST.ADMNO=SP.ADMNO ;

(a) A and B (b) B and C (c) A and D (d) C and D

v. Choose the command to count the number of students who play volleyball

(a) SELECT COUNT(*) FROM STUDENTS,SPORTS WHERE GAME="VOLLEYBALL" AND


STUDENTS.ADMNO =SPORTS.ADMNO;

(b) SELECT COUNT(GAME) FROM STUDENTS,SPORTS WHERE GAME="VOLLEYBALL"


AND STUDENTS.ADMNO=SPORTS.ADMNO;

(c) SELECT COUNT(*) FROM STUDENTS,SPORTS WHERE GAME="VOLLEYBALL" ;

(d) SELECT COUNT(*) FROM STUDENTS,SPORTS WHERE SPORTS="VOLLEYBALL"


AND STUDENTS.ADMNO =SPORTS.ADMNO;

43
6. A company ABC Enterprises has four iii. Which one of the following devices will
blocks of buildings as shown: you suggest for connecting all the
computers with in each of their blocks?
(a) Switch/Hub (b) Modem
(c) Telephone (d) Repeater

iv. The company is planning to link its


head office situated in New Delhi with
the offices in hilly areas. Suggest a
way to connect it economically:
Center to center distance between various
(a) Micro waves (b) Coaxial cable
blocks
B3 TO B1 50 M (c) Fibre optic (d) Radio waves
B1 TO B2 60 M v. Suggest the most appropriate location
B2 TO B4 25 M of the server, to get the best
B4 TO B3 170 M connectivity for maximum number of
B3 TO B2 125 M computers.
B1 TO B4 90 M (a) BLOCK B2 (b) BLOCK B1
Number of computers in each block :
(c) BLOCK B4 (d) BLOCK B3
B1 150 M
B2 15 M 7. Millions of computer science students have
B3 15 M taken a course on algorithms and data
structures, typically the second course after
B4 25 M
the initial one introducing programming.
Computers in each block are networked
One of the basic data structures in such a
but blocks are not networked. The company
course is the stack. The stack has a special
has now decided to connect the blocks also.
place in the emergence of computing as a
i. Suggest the most appropriate topology science, as argued by Michael Mahoney,
for the connections between the blocks. the pioneer of the history of the theory of
(a) Ring topology (b) Star topology computing. The Stack can be used in many
(c) Mesh topology (d) Bus topology computer applications, few are given below:

ii. The company wants internet (a) In recursive function


accessibility in all the blocks. The (b) When function is called.
suitable and cost-effective technology
(c) Expression conversion such as - Infix
for that would be:
(a) Satellite (b) Lease line to Postfix, Infix to Prefix, Postfix to Infix,
(c) Telephone line (d) Broadband Prefix to Infix.
44
In Stack, insertion operation is known as i. Identify the suitable code for the blank
Push whereas deletion operation is known of statement 1.
as Pop. (a) .append()
Code - 1 (b) .insert()

def push(Country,N): (c) .extend()

Country. (len(Country),N)) #Statement 1 (d) .append(len(Country),N)

#Function Calling Country=[] ii. Fill the statement 2, to insert the


C=['Indian', 'USA', 'UK', 'Canada', alternate element from Country list.

'Sri Lanka'] (a) 3 (b) 0

for i in range(0,len(C), ): #Statement 2 (c) -1 (d) 2

push(Country,C[i]) print(Country) iii. Fill the statement 3, to check the stack


is empty.
Required Output:
(a) Country=[]
['Indian', 'UK', 'Sri Lanka']
(b) Country.isEmpty()
Code - 2
(c) len(country)==0
def pop(Country):
(d) No of the above
if : #Statement 3
iv. Fill the statement 4, to delete an
return "Under flow"
element from the stack.
else:
(a) pop(1)
return Country. () #Statement 4
(b) pop()
#Function Calling (c) del country[1]
for i in range(len(Country)+1): (d) Country.delete(1)
print( ) #Statement 5
v. Fill the statement 5, to call the pop
Required Output: function.

Sri Lanka UK (a) pop(C)

India Under flow (b) pop(Country)

Fill the above statement based on given (c) call pop(Country)


questions: (d) def pop(Country)
45
8. Arun, during Practical Examination of ii. Identify the suitable code to be used
Computer Science, has been assigned an at blank space in line marked as
incomplete search() function to search in Statement- 2
a pickled file student.dat. The File (a) if(rec[0]==1) (b) for i in range(10)
student.dat is created by his Teacher
(c) try (d) pass
and the following information is known
about the file. iii. Identify the function (with argument),
to be used at blank space in line
 File contains details of students in
marked as Statement-3.
[roll_no,name,marks] format.
(a) load()
 File contains details of 10 students (i.e.
(b) load(student.dat)
from roll_no 1 to 10) and separate list of
(c) load(f)
each student is written in the binary file
using dump(). (d) load(fin)

Arun has been assigned the task to iv. What will be the suitable code for blank
complete the code and print details of roll space in line marked as Statement-4.
number 1.
(a) rec[0]==2 (b) rec[1]==2
def search():
(c) rec[2]==2 (d) rec[0]==1
f = open("student.dat",___) #Statement-1
v. Which statement Arun should use at
__________: #Statement-2
blank space in line marked as
while True: Statement- 4 to close the file.
rec = pickle. _______ #Statement-3 (a) file.close() (b) close(file)
if(___________): #Statement-4 (c) f.close() (d) close()

print(rec) 9. Radha Shah is a programmer, who has


except: recently been given a task to write a python

pass code to perform the following CSV file


operations with the help of two user defined
#Statement-5
functions/modules:
i. In which mode Arun should open the
(a) CSVOpen() : to create a CSV file
file in Statement-1?
called BOOKS.CSV in append mode
(a) r (b) r+ containing information of books - Title,
(c) rb (d) wb Author and Price.

46
(b) CSVRead() : to display the records i. Choose the appropriate mode in
from the CSV file called BOOKS.CSV which the file is to be opened in append
where the field title starts with 'R'. mode (Statement 1)

She has succeeded in writing partial (a) w+ (b) ab


code and has missed out certain (c) r+ (d) a
statements, so she has left certain
ii. Which statement will be used to create
queries in comment lines.
a csv writer object in Statement 2.
import csv
def CSVOpen(): (a) csv.writer(csvf)

with open('books.csv',' ______',newline='') (b) csv.writer(csvf)


as csvf: #Statement-1 (c) csvf.writer()
cw= ______ #Statement-2 (d) cs.writer(csvf)
#Statement-3
cw.writerow(['Rapunzel','Jack',300]) iii. Choose the correct option for Statement
3 to write the names of the column
cw.writerow(['Barbie','Doll',900])
headings in the CSV file, BOOKS.CSV.
cw.writerow(['Johnny','Jane',280])
(a) cw.writerow('Title','Author','Price')
def CSVRead():
try: (b) cw.writerow(['Title','Author','Price'])
with open('books.csv','r') as csvf: cr= (c) cw.writerows('Title','Author','Price')
#Statement-4 (d) cw.writerows(['Title','Author','Price'])
for r in cr:
iv. Which statement will be used to read
if : #Statement-5
a csv file in Statement 4.
print(r)
except: (a) cs.read(csvf) (b) csv.reader(csvf)

print('File Not Found') (c) csvf.read() (d) csvf.reader(cs)


CSVOpen()
v. Fill in the appropriate statement to
CSVRead() check the field Title starting with 'R' for
You as an expert of Python have to provide Statement 5 in the above program.
the missing statements and other related (a) r[0][0]=='R'
queries based on the following code of
(b) r[1][0]=='R'
Radha.
(c) r[0][1]=='R'
Answer any four questions (out of five) from
(d) r[1][1]=='R'
the below mentioned questions.
47
10. Ankita is writing a program to perform ii. Fill in the blank in Statement-2 to check
some operations in Queue. She has whether the queue is empty or not?
created three Insert_in_Queue(Student),
(a) isEmpty(Queue)
Delete_from_Queue(Student) and
Print_Queue(Student) methods/functions in (b) isEmpty(q)
Python to add a new Student name, delete (c) Queue.isEmpty
a Student name and print list of student
(d) Empty.Queue
from a queue, considering them to act as
insert, delete and print operations of the iii. iii. Fill in the blank in Statement-3 with
Queue data structure. She is not getting index number.
the desired result. Help her to get the
(a) delete(0) (b) del queue[0]
desired result from the given python code.
(c) delete.queue(0) (d) queue.delete[0]
def Insert_in_Queue(queue):
a=input("enter student name: ") iv. Select the correct option to complete
the statement at statement-4.
queue. ________ # Statement-1
(a) isEmpty( ) (b) Empty( )
def Delete_from_Queue (queue):
(c) len( ) = 0 (d) not Empty
if (________): # Statement-2
v. Specify the range to print all queue
print("Queue empty")
elements in statement-5?
else:
(a) print(queue=[0:len=(queue)])
print("Deleted element is: ",queue[0])
(b) print(queue[0:len(queue)])
del queue[ ______ ] #Statement-3
(c) print(queue[[0:len]])
def Print_Queue(queue):
(d) print(queue[0=len(queue)])
if not ________ : #Statement-4
print(queue[ :_______]) # Statement-5 11. Your teacher has given you a method/
function FilterWords() in python which read
i. What Ankita should write to complete the lines from a text file NewsLetter.TXT, and
Statement-1 to store the student name? display those words, which are lesser than
(a) queue.append(a) 4 characters. Your teachers intentionally

(b) queue=append(a) kept few blanks in between the code and


asked you to fill the blanks so that the code
(c) queue.append=a
will run to find desired result. Do the needful
(d) append(a).queue with the following python code.
48
def FilterWords(): ii. Fill in the blank in statement-2 to read
the data from the file.
c=0
(a) File.Read() (b) file.read()
file=open('NewsLetter.TXT', ' ____')
(c) read.lines( ) (d) readlines( )
#Statement-1
line = file_____. #Statement-2 iii. Fill in the blank in statement-3 to read
data word by word.
word =_______ #Statement-3
(a) Line.Split() (b) Line.split()
for c in word: (c) line.split() (d) split.word()
if __________: #Statement-4
iv. Fill in the blank in statement-4, which
print(c) display the word having lesser than 4
__________ #Statement-5 characters.
FilterWords() (a) len(c) ==4 (b) len(c)<4
(c) len ( )= =3 (d) len ( )==3
(i) Write mode of opening the file in
statement-1? v. Fill in the blank in Statement-5 to close
the file.
(a) a (b) ab (a) file.close() (b) File.Close()
(c) w (d) r (c) Close() (d) end()

ANSWER KEYS
1. i. (c) 4. i. (b) 7. i. (b) 10. i. (a)
ii. (b) ii. (d) ii. (d) ii. (a)
iii. (c) iii. (d) iii. (c) iii. (b)
iv. (d) iv. (b) iv. (b) iv. (a)
v. (c) v. (c) v. (b) v. (b)
2. i. (a) 5. i. (a) 8. i. (c) 11. i. (d)
ii. (c) ii. (a) ii. (c) ii. (b)
iii. (a) iii. (a) iii. (c) iii. (c)
iv. (a) iv. (c) iv. (d) iv. (b)
v. (d) v. (a) v. (c) v. (a)
3. i. (b) 6. i. (b) 9. i. (d)
ii. (d) ii. (d) ii. (b)
iii. (d) iii. (a) iii. (b)
iv. (c) iv. (d) iv. (b)
v. (d) v. (b) v. (a)
49
Sample Question Paper Class: XII
Session : 2021-22 Computer Science (Code 083)
(Theory: Term-1)
Maximum Marks: 35 Time Allowed: 90 Minutes
General Instructions:
 The question paper is divided into 3 Sections - A, B and C.
 Section A, consist of 25 Questions (1-25). Attempt any 20 questions.
 Section B, consist of 24 Questions (26-49). Attempt any 20 questions.
 Section C, consist of 6 case study based Questions (50-55). Attempt any 5 questions.
 All questions carry equal marks.
Section-A
This section consists of 25 Questions (1 to 25). Attempt any 20 questions from this section. Choose the
best possible option.
1. Find the invalid identifier from the 5. Which of the following options can be
following used to read the first line of a text file
(a) none (b) address Myfile.txt?
(c) name (d) pass (a) myfile = open('Myfile.txt'); myfile.read()
2 Consider a declaration L = (1, 'Python', (b) myfile = open('Myfile.txt','r'); myfile.read(n)
'3.14'). Which of the following represents (c) myfile = open('Myfile.txt'); myfile.readline()
the data type of L? (d) myfile = open('Myfile.txt'); myfile.readlines()
(a) list (b) tuple
6. Assume that the position of the file
(c) dictionary (d) string pointer is at the beginning of 3rd line
3. Given a Tuple tup1= (10, 20, 30, 40, 50, in a text file. Which of the following
60, 70, 80, 90). option can be used to read all the
remaining lines?
What will be the output of print (tup1 [3:7:2])?
(a) myfile.read()
(a) (40,50,60,70,80) (b) (40,50,60,70)
(b) myfile.read(n)
(c) (40,60) (d) (40,60) (c) myfile.readline()
4. Which of the following option is not (d) myfile.readlines()
correct? 7. A text file student.txt is stored in the
(a) if we try to read a text file that does not storage device. Identify the correct
exist, an error occurs. option out of the following options to
(b) if we try to read a text file that does not open the file in read mode.
exist, the file gets created. (i) myfile = open('student.txt','rb')
(ii) myfile = open('student.txt','w')
(c) if we try to write on a text file that does
not exist, no error occurs. (iii) myfile = open('student.txt','r')
(iv) myfile = open('student.txt')
(d) if we try to write on a text file that does (a) only i (b) both i and iv
not exist, the file gets created. (c) both iii and iv (d) both i and iii
50
8. The return type of the input() function 13. Which of the following statement is true?
is (a) pickling creates an object from a
(a) string (b) integer sequence of bytes
(c) list (d) tuple (b) pickling is used for object serialization
9. Which of the following operator cannot (c) pickling is used for object deserialization
be used with string data type? (d) pickling is used to manage all types of
(a) + (b) in files in Python
(c) * (d) /
14. Syntax of seek function in Python is
10. Consider a tuple tup1 = (10, 15, 25, and myfile.seek(offset, reference_point)
30). Identify the statement that will where myfile is the file object. What is
result in an error. the default value of reference_point?
(a) 0 (b) 1
(a) print(tup1[2]) (b) tup1[2] = 20 (c) 2 (d) 3
(c) print(min(tup1)) (d) print(len(tup1))
15. Which of the following components
are part of a function header in Python?
11. Which of the following statement is
incorrect in the context of binary (a) Function Name
files? (b) Return Statement
(c) Parameter List
(a) Information is stored in the same
format in which the information is held (d) Both a and c
in memory. 16. Which of the following function header
(b) No character translation takes place is correct?
(a) def cal_si(p=100, r, t=2)
(c) Every line ends with a new line
(b) def cal_si(p=100, r=8, t)
character
(c) def cal_si(p, r=8, t)
(d) Pickle module is used for reading and
(d) def cal_si(p, r=8, t=2)
writing
12. What is the significance of the tell() 17. Which of the following is the correct
way to call a function?
method?
(a) my_func() (b) def my_func()
(a) tells the path of file
(c) return my_func (d) call my_func()
(b) tells the current position of the file
pointer within the file 18. Which of the following character acts
(c) tells the end position within the file as default delimiter in a csv file?

(d) checks the existence of a file at the (a) (colon) : (b) (hyphen) -
desired location (c) (comma) , (d) (vertical line) |
51
19. Syntax for opening Student.csv file in 23. Which of the following symbol is used
write mode is myfile = open in Python for single line comment?
("Student.csv","w",newline='').
(a) / (b) /*
What is the importance of newline=''?
(c) // (d) #
(a) A newline gets added to the file
24. Which of the following statement
(b) Empty string gets appended to the
opens a binary file record.bin in write
first line.
mode and writes data from a list lst1 =
(c) Empty string gets appended to all lines. [1,2,3,4] on the binary file?
(d) EOL translation is suppressed a. with open('record.bin','wb') as myfile:
20. What is the correct expansion of CSV pickle.dump(lst1,myfile)
files? b. with open('record.bin','wb') as myfile:
(a) Comma Separable Values pickle.dump(myfile,lst1)

(b) Comma Separated Values c. with open('record.bin','wb+') as myfile:


pickle.dump(myfile,lst1)
(c) Comma Split Values
d. with open('record.bin','ab') as myfile:
(d) Comma Separation Values
pickle.dump(myfile,lst1)
21. Which of the following is not a function
/ method of csv module in Python? 25. Which of these about a dictionary
is false?
(a) read() (b) reader()
a) The values of a dictionary can be
(c) writer() (d) writerow()
accessed using keys
22. Which one of the following is the b) The keys of a dictionary can be
default extension of a Python file? accessed using values
(a) .exe (b) .p++ c) Dictionaries aren't ordered
(c) .py (d) .p d) Dictionaries are mutable

52
Section-B
This section consists of 24 Questions (26 to 49). Attempt any 20 questions.

26. What is the output of following code: 30. Identify the output of the following
T=(100) Python statements.
print(T*2) b=1
(a) Syntax error (b) (200,) for a in range(1, 10, 2):
(c) 200 (d) (100,100) b += a + 2
print(b)
27. Suppose content of 'Myfile.txt' is:
(a) 31 (b) 33
Twinkle twinkle little star
How I wonder what you are (c) 36 (d) 39
Up above the world so high 31. Identify the output of the following
Like a diamond in the sky Python statements.
What will be the output of the following lst1 = [10, 15, 20, 25, 30]
code? lst1.insert( 3, 4)
myfile = open("Myfile.txt") data = lst1.insert( 2, 3)
myfile.readlines() print(len(data))
print (lst1[-5])
myfile.close()
(a) 2 (b) 3
(a) 3 (b) 4
(c) 4 (d) 20
(c) 5 (d) 6
32. Raghav is trying to write a tuple tup1 =
28. Identify the output of the following (1,2,3,4,5) on a binary file test.bin.
Python statements. Consider the following code written by
x = [[10.0, 11.0, 12.0],[13.0, 14.0, 15.0]] him.
y = x[1][2] import pickle
print(y) tup1 = (1,2,3,4,5)
(a) 12.0 (b) 13.0 myfile = open("test.bin",'wb') pickle.
(c) 14.0 (d) 15.0 _________ #Statement 1

29. Identify the output of the following myfile.close()


Python statements. Identify the missing code in Statement 1.
x=2
(a) dump(myfile,tup1)
while x < 9:
(b) dump(tup1, myfile)
print(x, end='') x = x + 1
(a) 12345678 (b) 123456789 (c) write(tup1,myfile)

(c) 2345678 (d) 23456789 (d) load(myfile,tup1)


53
33. A binary file employee.dat has 35. Evaluate the following expression and
following data identify the correct answer.
Empno Empname Salary 16 - (4 + 2) * 5 + 2**3 * 4
101 Anuj 50000 (a) 54 (b) 46
102 Arijita 40000 (c) 18 (d0 32
103 Hanika 30000 36. What will be the output of the following
104 Firoz 60000 code?
105 Vijaylakshmi 40000 def my_func(var1=100, var2=200): var1+=10
def display(eno): f=open("employee.dat","rb") var2 = var2 - 10 return
var1+var2
totSum=0
print(my_func(50),my_func())
try:
(a) 100 200 (b) 150 300
while True: (c) 250 75 (d) 250 300
R=pickle.load(f) if
37. What will be the output of the following
R[0]==eno: code?
_____________ #Line1 value = 50
totSum=totSum+R[2] def display(N): global value value = 25
except: if N%7==0:
f.close() value = value + N else:
print(totSum) value = value - N print(value, end="#")
When the above mentioned function, display(20)
display (103) is executed, the output print(value)
displayed is 190000. (a) 50#50 (b) 50#5
Write appropriate jump statement from the (c) 50#30 (d) 5#50#
following to obtain the above output.
38. What will be the output of the following
(a) jump (b) break
code?
(c) continue (d) return
import random
34. What will be the output of the following List=["Delhi","Mumbai","Chennai","Kolkata"]
Python code? for y in range(4):
def add (num1, num2): sum = x = random.randint(1,3)
num1 + num2 print(List[x],end="#")
sum = add(20,30) (a) Delhi#Mumbai#Chennai#Kolkata#
print(sum) (b) Mumbai#Chennai#Kolkata#Mumbai#
(a) 50 (b) 0 (c) Mumbai# Mumbai #Mumbai # Delhi#
(c) Null (d) None (d) Mumbai# Mumbai #Chennai # Mumbai

54
39. What is the output of the following 42. Suppose content of 'Myfile.txt' is
code snippet?
Honesty is the best policy.
def ChangeVal(M,N): for i in range(N):
if M[i]%5 == 0: What will be the output of the following
code?
M[i]//=5 if M[i]%3 == 0:
M[i]//=3 L = [25,8,75,12] myfile = open("Myfile.txt") x =
ChangeVal(L,4) for i in L: myfile.read() print(len(x))
print(i,end="#") myfile.close()
(a) 5#8#15#4# (b) 5#8#5#4#
(a) 5 (b) 25
(c) 5#8#15#14# (d) 5#18#15#4#
(c) 26 (d0 27
40. Suppose content of 'Myfile.txt' is
Humpty Dumpty sat on a wall 43. Suppose content of 'Myfile.txt' is
Humpty Dumpty had a great fall Culture is the widening of the mind and of
All the king's horses and all the king's men the spirit.
Couldn't put Humpty together again What will be the output of the following
What will be the output of the following code?
code?
myfile = open("Myfile.txt")
myfile = open("Myfile.txt") record =
myfile.read().split() print(len(record)) x = myfile.read()
myfile.close() print(y)
(a) 24 (b) 25 y = x.count('the')
(c) 26 (d) 27
myfile.close()
41. Find the output of the following code: (a) 2 (b) 3
Name="PythoN3.1"
(c) 4 (d) 5
R=""
for x in range(len(Name)): if 44. What will be the output of the following
Name[x].isupper(): code?
R=R+Name[x].lower() x=3
elif Name[x].islower(): def myfunc(): global x x+=2
R=R+Name[x].upper() elif
print(x, end=' ')
Name[x].isdigit():
R=R+Name[x-1] print(x, end=' ')
else: myfunc()
R=R+"#" print(x, end=' ')
print(R)
(a) 3 3 3 (b) 3 4 5
(a) pYTHOn##@ (b) pYTHOnN#@
(c) pYTHOn#@ (d) pYTHOnN@# (c) 3 3 5 (d) 3 5 5

55
45. Suppose content of 'Myfile.txt' is 47. Consider the following directory
Ek Bharat Shreshtha Bharat structure.

What will be the output of the following


code?
myfile = open("Myfile.txt")
vlist = list("aeiouAEIOU")
vc=0 Suppose root directory (School) and
x = myfile.read() present working directory are the same.
What will be the absolute path of the file
for y in x:
Syllabus.jpg?
if(y in vlist):
(a) School/syllabus.jpg
vc+=1
(b) School/Academics/syllabus.jpg
print(vc)
(c) School/Academics/../syllabus.jpg
myfile.close()
(d) School/Examination/syllabus.jpg
(a) 6 (b) 7
(c) 8 (d) 9 48. Assume the content of text file,
'student.txt' is:
46. Suppose content of 'Myfile.txt' is
Arjun Kumar
Twinkle twinkle little star
Ismail Khan
How I wonder what you are
Joseph B
Up above the world so high
Hanika Kiran
Like a diamond in the sky
What will be the data type of data_rec?
Twinkle twinkle little star
What will be the output of the following myfile = open("Myfile.txt")
code? data_rec = myfile.readlines()
myfile = open("Myfile.txt") myfile.close()
line_count = 0 (a) string (b) list
data = myfile.readlines()
(c) tuple (d) dictionary
for line in data:
49. What will be the output of the following
if line[0] == 'T':
code?
line_count += 1
tup1 = (1,2,[1,2],3)
print(line_count)
tup1[2][1]=3.14
myfile.close()
print(tup1)
(a) 2 (b) 3
(a) (1,2,[3.14,2],3) (b) (1,2,[1,3.14],3)
(c) 4 (d) 5
(c) (1,2,[1,2],3.14) (d) Error Message
56
Section-C
Case Study based Questions
This section consists of 6 Questions (50 -55) Attempt any 5 questions.

Rohit, a student of class 12, is learning CSV 50. Identify the suitable code for blank space
File Module in Python. During examination, in the line marked as Statement-1.
(a) csv file (b) CSV
he has been assigned an incomplete
(c) csv (d) cvs
python code (shown below) to create a CSV
File 'Student.csv' (content shown below). 51. Identify the missing code for blank
space in line marked as Statement-2.
Help him in completing the code which
(a) "Student.csv","wb"
creates the desired CSV File.
(b) "Student.csv","w"
CSV File (c) "Student.csv","r"
1,AKSHAY,XII,A (d) "Student.cvs","r"
2,ABHISHEK,XII,A 52. Choose the function name (with
3,ARVIND,XII,A argument) that should be used in the
blank space of line marked as
4,RAVI,XII,A Statement-3.
5,ASHISH,XII,A (a) reader(fh) (b) reader(MyFile)
Incomplete Code (c) writer(fh) (d) writer(MyFile)

import #Statement-1 53. Identify the suitable code for blank space
in line marked as Statement-4.
fh = open( , , newline='')#Statement-2
(a) 'ROLL_NO', 'NAME', 'CLASS', 'SECTION'
stuwriter = csv. #Statement-3
(b) ROLL_NO, NAME, CLASS, SECTION
data = [ ]
(c) 'roll_no','name','Class','section'
header = ['ROLL_NO', 'NAME', 'CLASS', 'SECTION']
(d) roll_no,name,Class,section
data.append(header)
54. Identify the suitable code for blank space
for i in range(5):
in the line marked as Statement-5.
roll_no = int(input("Enter Roll Number : "))
(a) data (b) record
name = input("Enter Name : ") (c) rec (d) insert
Class = input("Enter Class : ")
55. Choose the function name that should
section =input("Enter Section") be used in the blank space of line
rec = [ ] #Statement-4 marked as Statement-6 to create the
desired CSV File?
data.append( ) #Statement-5
(a) dump() (b) load()
stuwriter. (data) #Statement-6
(c) writerows() (d) writerow()
fh.close()
57
ANSWER KEYS
Section-A Section-B Section-C
1. (d) 26. (c) 50. (c)
2. (b) 27. (b) 51. (b)
3. (d) 28. (d) 52. (c)
4. (b) 29. (c) 53. (d)
5. (c) 30. (c) 54. (c)
6. (d) 31. (b) 55. (c)
7. (c) 32. (b)
8. (a) 33. (c)
9. (d.) 34. (d)
10. (b) 35. (c)
11. (c) 36. (d)
12. (b) 37. (b)
13. (b) 38. (b)
14. (a) 39. (b)
15. (d) 40. (c)
16. (d) 41. (b)
17. (a) 42. (d)
18. (c) 43. (b)
19. (d) 44. (d)
20. (b) 45. (b)
21. (a) 46. (a)
22. (c) 47. (b)
23. (d) 48. (b)
24. (a) 49. (b)
25. (b)
58
Sample Question Paper Class: XII
Session : 2021-22 Computer Science (Code 083)
(Theory: Term-1)
Maximum Marks: 35 Time Allowed: 90 Minutes
General Instructions:
 The question paper is divided into 3 Sections - A, B and C.
 Section A, consist of 25 Questions (1-25). Attempt any 20 questions.
 Section B, consist of 25 Questions (26-50). Attempt any 20 questions.
 Section C, consist of 5 case study based Questions (51-55). Attempt any 5 questions.
 All questions carry equal marks.

Section-A 5. Which of the following statements are


true?
1. Which of the following is an invalid
(a) When you open a file for reading, if the
variable?
file does not exist, an error occurs
(a) my_string_1 (b) 1st_string
(b) When you open a file for writing, if the
(c) Foo (d) _ file does not exist, a new file is created
2. What type of data is: (c) When you open a file for writing, if the
arr = [(1,1),(2,2),(3,3)]? file exists, the existing file is overwritten
(a) Array of tuples (b) Tuples of lists with the new file

(c) List of tuples (d) Invalid type (d) All of the mentioned

3. Write the output of the following code 6. To open a file c:\scores.txt for
segment : appending data, we use ____________

for i in range(-1,-6,-5): (a) outfile = open("c:\\scores.txt", "a")

print(i*i) (b) outfile = open("c:\\scores.txt", "rw")

(a) 1 (b) 1 2 (c) outfile = open(file = "c:\scores.txt", "w")

(c) Error (d) Infinite loop (d) outfile = open(file = "c:\\scores.txt", "w")

4. What is the output of the following 7. What is the correct syntax of open()
program : function?
(a) file = open(file_name [, access_mode]
print((1, 2) + (3, 4))
[, buffering])
(a) (1, 2), (3, 4) (b) file object = open(file_name
(b) (4, 6) [, access_mode] [, buffering])
(c) (1, 2, 3, 4) (c) file object = open(file_name)

(d) Invalid Syntax (d) none of the mentioned

59
8. What is the two built-in functions to 14. Which of the following items are
read a line of text from standard input, present in the function header?
which is by default the keyboard? (a) function name (b) parameter list
(a) Insert (b) Input (c) return value (d) Both A and B
(c) Read (d) Scanner
15. Which of the following function
9. Which one of these is floor division? headers is correct?
(a) // (b) / (a) def fun(a = 2, b = 3, c)
(c) % (d) None of the above (b) def fun(a = 2, b, c = 3)
(c) def fun(a, b = 2, c = 3)
10. What will be the output of the following
Python code snippet? (d) def fun(a, b, c = 3, d)

d1 = {"john":40, "peter":45} 16. Which of the following would you


d2 = {"john":466,"peter":45} relate to a function call made with an
d1 > d2 argument passed as its parameter?
(a) True (b) False (a) function invocation
(c) Error (d) None (b) pass by value
(c) pass by reference
11. Which of the following is not true about
(d) pass by name
binary files?
(a) Binary files are store in terms of bytes 17. Which of the following is not a function
(b) When you open binary file in text editor of csv module?
will show garbage values (a) readline() (b) writerow()
(c) Binary files represent ASCII value of (c) reader() (d) writer()
characters
18. Which of these about a dictionary is
(d) All of the above
false?
12. This method returns an integer that (a) The values of a dictionary can be
specifies the current position of the file accessed using keys
object. (b) The keys of a dictionary can be
(a) seek() (b) load() accessed using values
(c) position() (d) tell() (c) Dictionaries may or may not be ordered
(d) None of the above
13. Which module is to be imported for
working in binary file? 19. What is output for 2 * 2 **3
(a) unpickle (b) pickle (a) 12 (b) 64
(c) pickling (d) unpickling (c) 16 (d) 35
60
20. Which of the following statements are Section-B
true?
26. To read the next line of the file from a
(a) When you open a file for reading, if the
file object infile, we use ____________
file does not exist, an error occurs
(a) read(2) (b) infile.read()
(b) When you open a file for writing, if the
file does not exist, a new file is created (c) readline() (d) infile.readlines()
(c) When you open a file for writing, if the 27. Which of the following file mode is not
file exists, the existing file is overwritten a valid file mode?
with the new file (a) rw (b) ab
(d) All of the mentioned (c) w+ (d) r+
21. What is output of 33 == 33.0 28. If we want to add more contents in an
(a) False (b) True existing file, file must be opened
(c) 33 (d) None of the above in…………mode.

22. Functions that do not return any value (a) binary (b) append
are known as (c) write (d) it is not possible
(a) fruitful functions 29. Which method is used to convert Python
(b) void functions objects for writing data in binary file?
(c) library functions
(a) write() (b) load()
(d) user-defined functions
(c) store() (d) dump()
23. A variable created or defined within a
function body is classified as- 30. Which is not the valid mode for binary
(a) Local (b) global files?
(c) instance (d) build-in (a) r (b) rb
24. Give output: (c) wb (d) wb+
s='Welcome to SPSEC' 31. Which of the following function is used
print(s.find('come'), end= "") to read the data in binary file?
print(s.find('o')) (a) read() (b) open()
(a) 4 3 (b) 3 4 (c) dump() (d) load()
(c) 3 3 (d) 4 4
32. Suresh wants to open the binary file
25. Give output:
student.dat in read mode. He writes the
s='My'
following statement but he does not know
s1='City'
the mode. Help him to find the same.
s2=s[:1]+s1[len(s1)-1:]
print(s2) F=open('student.dat', ____)
(a) MyCity (b) CityMy (a) r (b) rb
(c) Mt d (d) My (c) w (d) wb
61
33. What is the output of the following 36. What is the output of the following
program? program?
L= list('123456') L1=[ ]
L[0]=L[5]=0 L1.append([1,[2,3],4])
L[3]=L[-2] L1.extend([7,8,9])
print (L) print(L1[0][1][1]+L1[2])
(a) [0, '2', '3', '4', '5', 0] (a) Type Error: can only concatenate list
(b) ['6', '2', '3', '5', '5', '6'] (not "int") to list
(c) ['0', '2', '3', '5', '5', '0'] (b) 12
(d) [0, '2', '3', '5', '5', 0] (c) 11
34. What is the result of executing the (d) 38
following code?
37. What will be the output of the following
number=5
Python code?
while number <=5:
def f1(a,b=[]):
if number <5:
b.append(a)
number=number+1
return b
print(number)
print (f1(2,[3,4]))
a) The program will loop indefinitely (a) [3,2,4] (b) [2,3,4]
b) The value of number will be printed (c) [3,4,2] (d) Error
exactly 1 time
38. What is the output?
c) The while loop will never get executed
Y=[2,5J,6]
d) The value of number will be printed
Y.sort()
exactly 5 times
(a) [2,6,5J] (b) [5J,2,6]
35. What is the output of the following? (c) [6,5J,2] (d) Error
i=1
39. What will be the output of the following
while True:
program?
if i%007==0: tuple=("Check")*3
break print (tuple)
print(i) (a) Unexpected
i+=1 (b) (3Check)
(a) 1 2 3 4 5 6 (b) 1 2 3 4 5 6 7 (c) CheckCheckCheck
(c) Error (d) None of these (d) Syntax Error
62
40. Predict the output of the following code: print(d) # First Print Statement
x,y=2,4 f.seek(10)
if(x+y= =10): d=f.read(3)
print("true") print(d) # Second Print Statement
else: f.seek(13)
print("false") d=f.read(5)
(a) true (b) false print(d) # Third Print Statement
(c) no output (d) none d=f.tell()
print(d) # Fourth Print Statement
41. Choose the answer for statement 1
(a) Hello
import_____________ #statement 1
(b) Hell
rec=[]
(c) Ello
while True:
d) None of the above
rn=int(input("Enter"))
nm= input("Enter") 43. Ram opened a file in a certain mode.
temp=[rn,nm] After opening the file, he forgot the
rec.append(temp) mode. The interesting facts about that
mode are " If the file doesn't exist, then
ch=input("enter choice(Y/N)")
a new file will be created" and "After
ifch.upper== "N": opening file in that mode the file
break handle will be at the end of the file"
F=open("stud.dat","____") #statement 2 Help him to identify the correct mode.
_________.dump(rec,f) #statement 3 (a) read mode
______.close() #statement 4 (b) write mode
(a) csv (b) unpickle (c) append mode
(c) pickle (d) load (d) binary and read mode
44. What is the output of the following code.
42. Write the output of the First Print
statements : defouterFun(a,b):

f=open("data.txt",'w') definnerFun(c,d):

f.write("Hello") returnc+d

f.write("Welcome to my Blog") returninnerFun(a,b)

f.close() res=outerFun(5,10)

f=open("data.txt", 'r') print(res)

d=f.read(5) (a) 15 (b) Syntax Error


(c) (5, 10) (d) (10,5)
63
45. What will be printed when the 48. What will be the output of following
following code executes? Python code?
def test(a,b=5): x=['ab', 'cd']
print(a,b) for i in x:
test(-3) x.append(i.upper())
(a) -3, b (b) a, 5 print(x)
(c) -3, 5 (d) -3 5
(a) ['AB', 'CD']
46. What value is printed when the (b) ['ab', 'cd', 'AB', 'CD']
following code is executed?
(c) ['ab', 'cd']
name="Jane Doe"
(d) None of mentioned
defmyFunction (parameter):
value="First" 49. What is printed by the following
value= parameter statements?

print (value) D={"cat":12, "dog": 10, "cow": 20, "bear":25}

myFunction("Second") print(25 in D)
(a) Value (b) Second (a) True
(c) Parameter (d) First (b) False

47. What will be the output of the following (c) Error


snippet?
(d) None
f = None
for i in range (5): 50. Given tup=(5,3,1,9,0), which of the
following two statements will give the
with open ("data.txt", "W") as f:
same output?
if i > 2:
break (a) print(tup[:-1])
print (f.closed) (b) print(tup[0:5])
(a) True (b) False (c) print(tup[0:4])
(c) None (d) Error
(d) print(tup[-4:])

64
Section-C Answer questions (51-55)
based on above case study
(Case Study Based Question)
Mr. Zack Sullivan loves programming. He 51. Help Zack to import the module to perform
joined an institute for learning. He is learning binary file operation in statement 1.
python. He learned all the python concepts (a) csv (b) random
like strings, lists, tuple, dictionaries etc. but (c) pickle (d) file
he wants to learn file handling in python. He
52. Which statement is used from the
is trying to learn binary file handling. His
following for statement 2 to open the
teacher gave him partial code to write and
binary file in write mode?
read data from employee.dat having
(a) open("employee.dat",'w')
structure empno, name, salary. Help Zack
(b) open("employee.dat",'wb')
to complete the code: (c) open("employee.dat",'w+')
___________________ # statement 1 (d) open("employee.dat",'r')
Def addrecords(): 53. Which statement is used from the
fw= _____________ #statement 2 following for statement 3 to write
dictionary data created in above code,
dict={}
namely dict, is written in binary file
ch='y' employee.dat file?
whilech=='y': (a) dump(dict,fw)
(b) pickle.write(dict,fw)
eno=int(input("enter employee number"))
(c) save(dict,fw)
nm= input("enter employee name") (d) pickle.store(dict)
sal=int(input("enter employee salary"))
54. Which statement is used from the
dict={'empno':eno,'name':nm,'salary':sal} following for statement 4 to open the
____________________ # statement 3 binary file in read mode?
(a) open("employee.dat",'r')
ch=input("add more record") (b) open("employee.dat",'r+')
fw.close() (c) open("employee.dat",'a')
(d) open("employee.dat",'rb')
# function to display records
55. Compelete statement 5 to read data in
def display():
dictionary namely dict from the
dict={} opened binary file?
fr= _____________ # statement 4 (a) dict=pk.read(fr)
dict=____________ # statement 5 (b) dict=pickle.load(fr)
fr.close() (c) load(dict,fr)
print("data :",dict) (d) none of these
65
ANSWER KEYS
Section-A Section-B Section-C
1. (b) 26. (c) 51. (c)
2. (c) 27. (a) 52. (b)
3. (a) 28. (b) 53. (a)
4. (c) 29. (d) 54. (d)
5. (d) 30. (a) 55. (c)
6. (a) 31. (d)
7. (b) 32. (b)
8. (b) 33. (c)
9. (a) 34. (a)
10. (d) 35. (d)
11. (c) 36. (c)
12. (d) 37. (c)
13. (b) 38. (d)
14. (d) 39. (c)
15. (c) 40. (b)
16. (b) 41. (c)
17. (a) 42. (a)
18. (c) 43. (c)
19. (c) 44. (a)
20. (d) 45. (c)
21. (b) 46. (b)
22. (b) 47. (d)
23. (a) 48. (b)
24. (b) 49. (b)
25. (d) 50. (b)
66
TERM-II
UNIT - I
Computational Thinking and Programming - 2
1. A stack is which of the following type 5. In a stack, if a user tries to remove an
of data structure? element from empty stack it is called
(a) Linear .
(b) Dynamic (a) Underflow
(c) Circular
(b) Empty collection
(d) All of these
(c) Overflow
2. Stack data structure is following
(d) Garbage Collection
principle.
(a) LIFO 6. Entries in a stack are "ordered". What
(b) FIFO is the meaning of this statement?

(c) Both A & B (a) A collection of stacks is sortable


(d) None of these (b) Stack entries may be compared with
the '<' operation
3. Process of inserting an element in
stack is called . (c) The entries are stored in a linked list
(a) Create (b) Push (d) There is a Sequential entry that is one
(c) Evaluation (d) Pop by one

4. Which of the following is true about 7. Process of removing an element from


linked list implementation of stack?
stack is called
(a) In push operation, if new nodes are
(a) Create (b) Push
inserted at the beginning of linked list,
then in pop operation, nodes must be (c) Evaluation (d) Pop
removed from end.
8. Pushing an element into stack already
(b) In push operation, if new nodes are
having five elements and stack size
inserted at the end, then in pop
operation, nodes must be removed of 5, then stack becomes
from the beginning. (a) Overflow (b) Crash
(d) Both of the above (c) Underflow (d) User flow
67
9. Which of the following applications 10. The data structure required to check
may use a stack? whether an expression contains
balanced parenthesis is?
(a) A parentheses balancing program
(a) Stack
(b) Tracking of local variables at run time
(b) Queue
(c) Compiler Syntax Analyzer
(c) Array
(d) All of the mentioned (d) Tree

ANSWER KEYS
1. (a) 6. (d)
2. (a) 7. (d)
3. (b) 8. (a)
4. (d) 9. (d)
5. (a) 10. (a)

Long Type Questions


1. What is a Stack? What basic operations can be performed on them?

Stack is a basic data structure where insertion and deletion of data takes place at one end
called the top of the Stack, i.e., it follows the Last-In-First-Out (LIFO) principle.

Following basic operations can be performed on Stacks.

(i) PUSH, i.e., insertion of element in the Stack

(ii) POP, i.e., deletion of an element from the Stack

(iii) Displaying all the elements in the Stack.

2. What do you mean by data structure? Explain your answer with a suitable example.

3. What do you mean by the LIFO structure? Support your answer with real-life examples.

4. Enlist a few of the fields where you feel a stack is used in real life.

5. What are the basic operations that can be performed on the stack?

6. What are the underflow and overflow conditions?

7. Write steps on how you implement stack?

68
UNIT - II
Computer Networks
SET - I
1. A set of nodes connected by 6. is a set of rules which govern
is called a Network. data communication.
(a) link (b) wire (a) Protocol (b) Message
(d) hardware (d) None of these (c) Information (d) All of these

2. Computer Network is 7. What is the meaning of Bandwidth in


(a) Collection of hardware components Network?
and computers (a) Transmission capacity of a
(b) Interconnected by communication communication channels
channels (b) Connected Computers in the Network
(c) Sharing of resources and information (c) Class of IP used in Network
(d) All of the Above (d) None of Above

3. The best example of computer network 8. Repeater operates in which layer of the
is . OSI model?
(a) Switch (d) Router
(a) Physical layer
(c) Internet (d) None of these
(b) Data link layer
4. How many layers of OSI Reference
(c) Network layer
Model have?
(d) Transport layer
(a) 4 (b) 5
(c) 6 (d) 7 9. is to regenerate the signal
over the same network before the
5. The exchange of data between two signal becomes too weak.
devices through transmission medium
(a) Hub (b) Repeater
is called .
(a) Communication (c) Switch (d) Router

(b) Data Communication 10. A is a multiport repeater..

(c) Both A & B (a) Hub (b) Bridge

(d) None of these (c) Switch (d) Gateway

69
11. Bridge works in which layer of the 16. normally connects LANs
OSI model? and WANs together.
(a) Application layer (a) Hub (b) Bridge

(b) Transport layer (c) Switch (d) Routers

(c) Network layer 17. Routing tables of a router keeps track


(d) Data link layer of .
(a) MAC Address Assignments
12. What is the use of Bridge in Network?
(b) Port Assignments to network devices
(a) to connect two LANs
(c) Distribute IP address to network devices
(b) to separate LANs
(c) to control Network Speed (d) Routes to use for forwarding data to
its destination
(d) All of the above
18. Layer-2 Switch is also called
13. A is used to connect two
LANs working on same protocol. (a) Multiport Hub

(a) Hub (b) Bridge (b) Multiport Switch


(c) Switch (d) Gateway (c) Multiport Bridge
(d) Multiport NIC
14. Router operates in which layer of OSI
Reference Model? 19. A is a multi-port bridge with
(a) Physical Layer a buffer.

(b) Network Layer (a) Hub (b) Bridge

(c) Transport Layer (c) Switch (d) Routers

(d) Application Layer 20. A is designed for small


physical areas such as an office, group
15. What does Router do in a network?
of buildings within 10KM radius.
(a) Forwards a packet to all outgoing links
(a) LAN (b) WAN
(b) Forwards a packet to the next free
(c) MAN (d) None of these
outgoing link
(c) Determines on which outing link a 21. A covers towns and cities
packet is to be forwarded within 50KM radius.

(d) Forwards a packet to all outgoing links (a) LAN (b) WAN
except the originated link (c) MAN (d) None of these

70
22. It is used for the network that covers 28. Which of the following is Software?
large distance such as cover states
(a) Routers (b) Firewalls
and countries.
(a) LAN (b) WAN (c) Gateway (d) Modems
(c) MAN (d) None of these 29. Physical or logical arrangement of
23. is a standard for short- network is
distance wireless communication. (a) Topology
(a) Wi-Fi (b) WAN (b) Routing
(c) MAN (d) None of these
(c) Networking
24. Which of the following is/are the (d) None of the mentioned
advantages of wireless LANs.
i. Installation speed and simplicity 30. In which topology there is a central
ii. Installation flexibility controller or hub?
iii. Scalability (a) Star (b) Mesh
(a) i and ii only (b) ii and iii only (c) Ring (d) Bus
(c) i and iii only (d) All i, ii and iii
31. This topology requires multipoint
25. What does protocol defines? connection
(a) Protocol defines what data is (a) Star (b) Bus
communicated. (c) Ring (d) None of these
(b) Protocol defines how data is
communicated. 32. Bus, ring and star topologies mostly
(c) Protocol defines when data is used in the
communicated. (a) LAN (b) MAN
(d) All of above (c) WAN (d) Internetwork

26. What is the benefit of the Networking? 33. Combination of two or more
(a) File Sharing topologies are called
(b) Easier access to Resources (a) Star (b) Bus
(c) Easier Backups
(c) Ring (d) Hybrid
(d) All of the Above
34. Which of the following is not type of
27. Which of the following is not the
the network topology?
Networking Devices?
(a) Gateways (b) Window (a) Mesh (b) Bus

(c) Routers (d) Firewalls (c) Ring (d) Stub

71
35. In a network with 24 computers, which 41. Internet is
topology would require the most (a) A local computer network
extensive cabling? (b) A worldwide network of computers
(a) Bus (b) Mesh (c) An interconnected network of
computers
(c) Star (d) Tree
(d) A worldwide interconnected network of
36. Mesh topology has physical computers which use a common protocol
channels to link 'n' devices. to Communicate with one another

(a) n (b) n(n-1)/2 42. Internet requires


(c) (n-1) (d) None of these (a) An international agreement to connect
computers
37. In the star topology we use a central (b) A local area network
device (c) A commonly agreed set of rules to
(a) Hub (b) Electrical cable communicate between computers

(c) Bus (d) None of these (d) A World Wide Web

38. Which topology is called completely 43. Each computer connected to the
internet must
connected network?
(a) Be an IBM PC
(a) Star (b) Mesh
(b) Have a unique IP address
(c) Tree (d) Bus (c) Be internet compatible

39. Data communication system spanning (d) Have a modem connection


states, countries, or the whole world 44. is a device that routes data
is packets based on their IP address.
(a) LAN (a) Router (b) Bridge
(b) WAN (c) Switch (d) Gateway

(c) MAN 45. Which of the following is a type of


computer network?
(d) None of the mentioned
(a) Telnet (b) MAN
40. Expand WAN? (c) Bluetooth (d) HTTP
(a) World Area Network 46. Which of the following is a valid
(b) Wide Area Network network topology?
(c) Web Area Network (a) WAN (b) MAN

(d) None of the mentioned (c) Ring (d) PAN

72
47. Which network device is used to amplify 54. is used for FTP data.
signal in long-distance networking?
(a) Port 20 (b) Port 21
(a) Switch (b) Repeater
(c) Port 22 (d) Port 23
(c) Hub (d) Bridge
55. The File Transfer Protocol is built on
48. WLL stands for .
.
(a) Wireless Local Loop
(a) data centric architecture
(b) Wireless local Link
(b) service oriented architecture
(c) Wire Less link
(c) client server architecture
(d) None of these
(d) connection oriented architecture
49. Modem is used mostly for?
(a) Mostly for file system 56. IPv4 address length is bits.

(b) A modern empty memory modules (a) 16 (b) 32


(c) Connecting to internet (c) 64 (d) 128
(d) None of above 57. How many address space can be
50. Which type of cable is most likely in generated in IPv4?
use with rj-45 connectors? (a) 216 (b) 232
(a) 10base2 (b) 10base5 (c) 2 64 (d) 2 128
(c) 10baseT (d) 10baseFL
58. IPv6 address length is bits.
51. HTTP is protocol. (a) 16 (b) 32
(a) application layer (b) transport layer (c) 64 (d) 128
(c) network layer (d) data link layer
59. Identify the class of the following IP
52. In the network HTTP resources are address: 191.1.2.3.
located by
(a) class A (b) class B
(a) uniform resource identifier
(c) class C (d) none of the above
(b) unique resource locator
(c) unique resource identifier 60. A host can get its IP address from its
(d) union resource locator server by using as the
source address and as the
53. The term FTP stands for? destination address.
(a) File transfer program (a) 255.255.255.255; 0.0.0.0
(b) File transmission protocol (b) 127.0.0.0; 255.255.255.255
(c) File transfer protocol (c) 0.0.0.0; 255.255.255.255
(d) File transfer protection (d) None of the above
73
ANSWER KEYS
1. (a) 21. (c) 41. (d)

2. (d) 22. (b) 42. (c)

3. (c) 23. (a) 43. (b)

4. (d) 24. (d) 44. (a)

5. (b) 25. (d) 45. (b)

6. (a) 26. (d) 46. (c)

7. (a) 27. (b) 47. (b)

8. (a) 28. (b) 48. (a)

9. (b) 29. (a) 49. (c)

10. (a) 30. (a) 50. (c)

11. (d) 31. (b) 51. (a)

12. (a) 32. (a) 52. (b)

13. (b) 33. (d) 53. (c)

14. (b) 34. (d) 54. (a)

15. (c) 35. (b) 55. (c)

16. (d) 36. (b) 56. (b)

17. (d) 37. (a) 57. (b)

18. (c) 38. (b) 58. (d)

19. (c) 39. (b) 59. (b)

20. (a) 40. (b) 60. (c)

74
SET - II
1. A Computer Network:
(a) Is a collection of hardware components 6. MAN Stands for _____.
and computers?
(a) Metropolitan Area Network
(b) Is interconnected by communication
channels (b) Main Area Network

(c) Allows sharing of resources and (c) Metropolitan Access Network


information (d) Metro Access Network
(d) All of the above
7. Which of the following is the smallest
2. What is a Firewall in computer network?
network?
(a) WAN (b) MAN
(a) The physical boundary of network
(b) An operating system of computer (c) PAN (d) LAN
network
8. Which transmission media is capable
(c) A system designed to prevent of having a much higher bandwidth
unauthorized access (data capacity)?
(d) A web browsing software
(a) Coaxial
3. What is the use of Bridge in the (b) Twisted pair cable
Network?
(c) Untwisted cable
(a) To connect LANs
(b) To separate LANs (d) Fiber optic

(c) To control network speed 9. Which type of transmission media is


(d) All of the above the least expensive to manufacture?

4. Each IP packet must contain: (a) Coaxial


(a) Only Source address (b) Twisted pair cable
(b) Only Destination address (c) CAT cable
(c) Source and Destination address
(d) Fiber optic
(d) Source or Destination address
10. A device that forwards data packet from
5. Which of these is not a communication
one network to another is called a
channel?
(a) Satellite (b) Microwave (a) Bridge (b) Router

(c) Radio wave (d) Wi-Fi (c) Hub (d) Gateway


75
11. What is a standalone computer? 17. What is the address size of IPv6?
(a) A computer that is not connected to a (a) 32 bit (b) 64 bit
network (c) 128 bit (d) 256 bit
(b) A computer that is being used as a server
18. Which of these is not an example of
(c) A computer that does not have any
unguided media?
peripherals attached to it
(a) Optical Fiber Cable
(d) A computer that is used by only one
person (b) Radio wave
(c) Bluetooth
12. Which of the following is the fastest (d) Satellite
media of data transfer?
(a) Co-axial Cable 19. Two devices are in network if
(b) Untwisted Wire (a) A process in one device is able to
(c) Telephone Lines exchange information with a process
(d) Fiber Optic in another device
(b) A process is running on both devices
13. Hub is a
(c) The processes running of different
(a) Broadcast device
devices are of same type
(b) Unicast device
(d) None of the above.
(c) Multicast device
(d) None of the above 20. Which of the following is not the
Networking Devices?
14. Switch is a
(a) Gateways (b) Linux
(a) Broadcast device
(b) Unicast device (c) Routers (d) Firewalls

(c) Multicast device 21. The location of a resource on the


(d) None of the above internet is given by its?

15. The device that can operate in place (a) Protocol (b) URL
of a hub is a: (c) E-mail address (d) ICQ
(a) Switch (b) Bridge
22. The term HTTP stands for?
(c) Router (d) Gateway
(a) Hyper terminal tracing program
16. In computer, converting a digital signal (b) Hypertext tracing protocol
in to an analog signal is called
(c) Hypertext transfer protocol
(a) modulation (b) demodulation
(d) Hypertext transfer program
(c) conversion (d) transformation
76
23. Which software prevents the external 30. is a collection of many separate
access to a system? networks.
(a) Firewall (b) Gateway (a) A MAN (b) An internet
(c) Router (d) Virus checker (c) A LAN (d) None of the above
31. A is a set of rules that governs data
24. Which one of the following is the most
communication.
common internet protocol?
(a) forum
(a) HTML (b) NetBEUI
(b) protocol
(c) TCP/IP (d) IPX/SPX
(c) standard
25. The term FTP stands for? (d) None of the above
(a) File transfer program
32. Which of the following is required to
(b) File transmission protocol
communication between two computers?
(c) File transfer protocol
(a) Communication hardware
(d) File transfer protection
(b) Communications software
26. Which one of the following is not a (c) Protocol
network topology? (d) All of above including access to
(a) Star (b) Ring transmission medium
(c) Bus (d) Peer to Pee 33. Bluetooth is an example of
(a) Wide area network
27. Which of the following is not an unit
for data transfer rate? (b) Virtual private network

(a) MBPS (b) KBPS (c) Local area network

(c) SBPS (d) GBPS (d) Personal area network

28. This was the first network. 34. A device which can be connected to a
network without using cable is called
(a) CSNET (b) NSFNET
(a) Distributed device
(c) ANSNET (d) ARPANET
(b) Centralized device
29. A is a data communication (c) Open-source device
system within a building, campus, or (d) Wireless device
between near by buildings.
(a) MAN 35. The vast network of computers that
(b) LAN connects millions of people all over the
world is called
(c) WAN
(a) Internet (b) Hypertext
(d) None of the above
(c) LAN (d) Web
77
36. MAC address is of . 42. Which of the following best describes
uploading information?
(a) 24 bits (b) 36 bits
(a) Sorting data on a disk drive
(c) 42 bits (d) 48 bits
(b) Sending information to a host computer
37. Which of the following appears
(c) Receiving information from a host
harmless but actually performs computer
malicious functions such as deleting
(d) Sorting data on a hard drive
or damaging files.

(a) WORM (b) Virus 43. The term IPv4 stands for?

(c) Trojan Horse (d) Malware (a) Internet Protocol Version 4


(b) Internet Programming Version 4
38. Name the protocol that is used to send
(c) International Programming Version 4
emails.
(d) None of these
(a) FTP (b) SMTP

(c) HTTP (d) TCP 44. In specific, if the systems use separate
protocols, which one of the following
39. Name the protocol that is used to devices is used to link two systems?
receive emails (a) Repeater (b) Gateway
(a) POP (b) VOIP (c) Bridge (d) Hub
(c) DHCP (d) FTP
45. DNS is the abbreviation of
40. Rajesh has purchased a new Smart TV (a) Dynamic Name System
and wants to cast a video from his (b) Dynamic Network System
mobile to his new Smart TV. Identify the
(c) Domain Name System
type of network he is using:
(d) Domain Network Service
(a) LAN (b) MAN
46. What is the meaning of Bandwidth in
(c) WAN (d) PAN
Network?
41. The topology in which all nodes are (a) Tr a n s m i s s i o n c a p a c i t y o f a
individually connected to a central communication channels
connection point:
(b) Connected Computers in the Network
(a) Ring (b) Bus (c) Class of IP used in Network
(c) Star (d) Tree (d) None of Above
78
47. What does protocol defines? 53. It can be a software program or a
(a) Protocol def ines what data is hardware device that filters all data
communicated. packets coming through the internet, a
network, etc. it is known as the .
(b) Protocol defines how data is
communicated. (a) Antivirus (b) Firewall

(c) Protocol defines when data is (c) Cookies (d) Malware


communicated. 54. The term "TCP/IP" stands for_____.
(d) All of above (a) Transmission Contribution Protocol/
Internet Protocol
48. Which of the following can be Software?
(b) Transmission Control Protocol /
(a) Routers (b) Firewalls Internet Protocol
(c) Gateway (d) Modems (c) Transaction Control protocol / Internet
Protocol
49. The loss in signal power as light travels
down the fiber is called_______. (d) Transmission Control Protocol /
Internet Protocol
(a) Attenuation (b) Propagation
(c) Scattering (d) Interruption 55. Which of the following is a type of
independent malicious program that
50. Which of the following TCP/IP never required any host program?
protocols is used for transferring files (a) Trojan Horse (b) Worm
form one machine to another? (c) Trap Door (d) Virus
(a) FTP (b) SNMP
(c) SMTP (d) RPC 56. In order to ensure the security of the
data / information, we need to _______
51. Which of the following protocol is used the data.
for remote terminal connection service? (a) Encrypt
(a) RARP (b) UDP
(b) Decrypt
(c) FTP (d) TELNET
(c) Delete
52. Which of the following is considered (d) None of the above
as the unsolicited commercial email?
(a) Virus 57. Firewall is the type of ________.
(a) Virus
(b) Malware
(b) Security threats
(c) Spam
(c) Worm
(d) All of the above (d) None of the above
79
58. It allows a visited website to store its 63. Which of the following devices is not
own information about a user on the a networking device?
user's computer:
(a) Hub
(a) Spam (b) Cookies
(b) Switch
(c) Malware (d) Adware
(c) Bridge
59. In which of the following switching
(d) None of these
methods, the message is divided into
small packets?
64. How many pins does RJ-45 contain?
(a) Message switching
(a) Two (b) Four
(b) Packet switching
(c) Eight (d) Ten
(c) Circuit switching
(d) None of these 65. NIC Stands for -
60. Which of the following switch methods (a) Network Identity Card
creates a point-to-point physical (b) Network Interface Code
connection between two or more
(c) National Interface Card
computers?
(a) Message switching (d) Network Interface Card

(b) Packet switching


66. Which of the following is not a type of
(c) Circuit switching guided or wired communication
(d) None of these channel?
61. MAC address is also called ______. (a) Twisted Pair (b) Coaxial
(a) Physical address (c) Fibre Optic (d) WiMax
(b) Logical address
(c) Source address 67. Which of the following is not a type of

(d) Destination address unguided or wireless communications


channel?
62. ARPANET stands for _______.
(a) Microwave (b) Radiowave
(a) Advanced Recheck Projects Agency
Internet (c) Ethernet (d) Sattelite
(b) Advanced Recheck Projects Agency
68. Which of the following wireless
Network
medium consists of a parabolic antena
(c) Advanced Research Projects Agency
mounted on towers?
Network
(d) Advanced Research Projects Agency (a) Sattelite (b) Radiowave
Internet (c) Microwave (d) Infrared
80
69. Which of the following cable consist 74. Which of the following allows user to
of a solid wire core surrounded by one view a webpage?
or more foil or wire shields? (a) Operating System

(a) Ethernet Cables (b) Website


(c) Interpreter
(b) Coaxial Cables
(d) Internet Browser
(c) Fiber Optic Cables
75. A network router joins two ________
(d) Power Cable together?
(a) Computers (b) Switches
70. A collection of hyperlinked documents
on the internet forms the ? (c) Networks (d) Gateway

(a) World Wide Web (WWW) 76. A network point that provides entrance
into another network is called as _____
(b) E-mail system
(a) Node (b) Gateway
(c) Mailing list (c) Switch (d) Router
(d) Hypertext 77. TELNET used _________ protocol for
data connection
71. Protocols are set of rules to govern
(a) TCP (b) UDP
_________
(c) IP (d) DHCP
(a) Communication
78. Google Chrome is example of
(b) Standard
(a) Programming Language
(c) Metropolitan communication (b) Web Server
(d) Bandwidth (c) Protocol
(d) Web Browser
72. An internet is a __________
79. Name the transmission media best
(a) Collection of WANS
suitable for connecting to hilly areas.
(b) Network of networks (a) Co-axial Cable (b) Twisted pair
(c) Collection of LANS (c) Microwave (d) Optical fiber
(d) Collection of identical LANS and 80. Rahul wants to establish computer
WANS network in his cyber café, which of the
following device will be suggested
73. Which protocol is commonly used to by you to connect each computer in
retrieve email from a mail server? the cafe?
(a) FTP (b) IMAP (a) Switch (b) Modem
(c) HTML (d) TELNET (c) Gateway (d) Repeater

81
ANSWER KEYS
1. (d) 21. (b) 41. (c) 61. (a)

2. (c) 22. (c) 42. (b) 62. (c)

3. (a) 23. (a) 43. (a) 63. (d)

4. (c) 24. (c) 44. (b) 64. (c)

5. (d) 25. (c) 45. (c) 65. (c)

6. (a) 26. (d) 46. (a) 66. (d)

7. (c) 27. (c) 47. (d) 67. (c)

8. (d) 28. (d) 48. (b) 68. (c)

9. (b) 29. (b) 49. (a) 69. (b)

10. (b) 30. (b) 50. (a) 70. (a)

11. (a) 31. (b) 51. (d) 71. (a)

12. (d) 32. (d) 52. (c) 72. (b)

13. (a) 33. (d) 53. (b) 73. (b)

14. (b) 34. (d) 54. (b) 74. (d)

15. (a) 35. (a) 55. (b) 75. (c)

16. (a) 36. (d) 56. (a) 76. (b)

17. (c) 37. (c) 57. (d) 77. (a)

18. (a) 38. (b) 58. (b) 78. (d)

19. (a) 39. (a) 59. (b) 79. (c)

20. (b) 40. (d) 60. (c) 80. (a)

82
Very Short Answer Type Questions (1 mark)
1. Give one example of each - Guided media 6. Name the transmission media suitable to
and unguided media. establish PAN.

2. Name the protocol that is used to transfer 7. Name the protocol that is used to upload
file from one computer to another. and download files on internet
8. Name the protocol that is used to send
3. Name the transmission media best
emails.
suitable for connecting to desert areas.
9. Name the protocol that is used to receive
4. Rearrange the following terms in increasing
emails.
order of speedy medium of data transfer:
10. Name the transmission media best
Telephone line, Fiber Optics, Coaxial
suitable for connecting to hilly areas.
Cable, Twisted Paired Cable.
11. Name the fastest available transmission
5. Which of the following appears harmless
media.
but actually performs malicious functions
such as deleting or damaging files. 12. Sunil has purchased a new Smart TV and
wants to cast a video from his mobile to
(a) WORM (b) Virus his new Smart TV. Identify the type of
(c) Trojan Horse (d) Malware network he is using and explain it.

ANSWER KEYS
1. Guided media- Twisted pair, Coaxial 7. FTP or HTTP
Cable, Optical Fiber (any one)
8. SMTP
Unguided media- Radio waves, Satellite,
Micro Waves (any one) 9. POP

2. FTP 10. Microwave / Radio wave.

3. Microwave 11. OFC (Optical Fiber Cable)


4. Telephone line, Twisted Pair Cable, 12. Sunil is using PAN-Personal Area
Coaxial Cable, Fiber Optics. Network. It is a private network which is
5. (c) Trojan Horse setup by an individual to transfer data
among his personal devices of home.
6. Bluetooth, infra-red

83
Short Answer Type Questions (2 marks)
1. Expand the following terms: 4. Differentiate between packet switching and
message switching technique in network
PAN LAN MAN WAN
communication.
IPR SIM IMAP HTTP
5. Which type of network (out of LAN, PAN
URL POP3 SMTP V0IP
and MAN) is formed, when you connect two
TCP Wi-Fi GPRS IRC mobiles using Bluetooth to transfer a
CDMA TDMA VPN FLOSS picture file?

XML SMS GSM PHP 6. What is the difference between HTTP


and FTP?
FTP DHCP WWW WLL
7. What is the advantage of using SWITCH
HTML
over HUB?
2. What is difference between star topology
8. What is difference between star topology
and bus topology of network?
and bus topology of network?
3. Write two advantages of using an optical
9. Define the term firewall.
fibre cable over an ethernet cable to
connect two service stations, which are 10. W hat is the importance of URL in
190 m away from each other. networking?

ANSWER KEYS
1. PAN - Personal Area Network SMTP - Simple Mail Transfer Protocol
LAN - Local Area Network V0IP - Voice over Internet Protocol
MAN - Metropolitan Area Network TCP - Transmission Control Protocol
WAN - Wide Area Network Wi-Fi - Wireless Fidelity
IPR - Intellectual Property Rights GPRS - General Packet Radio Service
SIM - Subscriber's Identity Module IRC - Internet Relay Chat
IMAP - Internet Message Access Protocol CDMA- Code Division Multiple Access
HTTP - Hypertext Transfer Protocol TDMA- Time Division Multiple Access
URL - Uniform Resource Locator VPN - Virtual Private Network
POP3 - Post office protocol ver. III FLOSS - Free Libre Open Source Software
84
XML - eXtensible Markup Language 5. When two mobiles are connected using
SMS - Short Messaging Service bluetooth to transfer a picture file, a PAN

GSM - Global system for mobile (Personal Area Network) is created.

communication 6. FTP is a protocol used to upload files from


PHP - Hypertext Preprocessor a workstation to a FTP server or download

FTP - File Transfer Protocol files from a FTP server to a workstation.


HTTP is a protocol used to transfer files
DHCP - Dynamic Host Configuration
from a web server onto a browser in order
Protocol
to view a web page that is on the Internet.
WWW - World Wide Web
7. Switch provides a dedicated line at full
WLL - Wireless Local Loop
bandwidth between two devices but hub
HTML - Hyper Text Markup Language
doesn't provide a dedicated line. Hub
2. In star topology, nodes are connected to shares the bandwidth.
server individually whereas in bus topology
8. In star topology, nodes are connected to
all nodes are connected to server along a
server individually whereas in bus topology
single length of cable.
all nodes are connected to server along a
3. Low power because signals in optical single length of cable.
fibers degrade less, lower power
9. Firewall is a feature used for Network
transmitters can be used. Higher data rate
Security. In a Network there is always danger
due to higher bandwidth, data rate of
of information leaking out or leaking in.
optical fiber is more than the data rate of
Firewall is a feature which forces all information
ethernet cable (upto 1 Gbps).
entering or leaving the network to pass
4. Message Switching In message switching through a check to make sure that there is
data is stored in buffer form. The message no unauthorized usage of the network.
is, sent to the nearest directly connected
10. URL stands for Uniform Resource Locator.
switching node. This process continues
Each page that is created for Web
until data is delivered to the destination
browsing is assigned a URL that effectively
computer. Packet Switching In this form of
serves as the page's worldwide name or
switching data is transferring into packet
address. URL's have three parts: the
form. A fixed size of packet that can be
protocol, the DNS name of the machine on
transmitted across the network is
which the page is located and a local name
specified. All the packets are stored in the
uniquely indicating the specific page
main memory instead of disk.
(generally the filename)
85
Long Answer Type Questions
1. What is Computer Network? Discuss various types of computer networks with its advantages
and disadvantages.

2. What is a network? What are its goals and applications?

3. Explain various wired and wireless technologies used in communication networks. Also highlight
their merits and demerits.

4. What is a network topology? Explain the working of different topologies highlighting their merits
and demerits.

5. Write the name of three network topologies. Describe them with their advantages and
disadvantages.

6. Discuss and compare various types of networks.

7. What are hubs? What are its types?

8. What is the role of a switch in a network?

9. Briefly discuss the role of following devices in the context of networking.

(i) Router (ii) bridge (iii) gateway

10. When would you prefer

(i) bridges over hubs

(ii) switch over other network devices?

11. Discuss IP Address in brief.

12. When would you opt for a router in a network?

13. What are hubs? How are active hubs different from passive hubs?

14. What are the facilities provided by the SERVER in a Network environment?

15. Compare circuit switching and packet switching.

16. Write Notes on:

(i) HTTP (ii) FTP (iii) WWW (iv) PPP

86
UNIT - III
Database Management
SET - I
1. What is the full form of SQL? 6. The term is use to refer to a
(a) Structured Query Language record in a table.
(b) Structured Query List (a) Attribute (b) Tuple
(c) Simple Query Language (c) Row (d) Instance
(d) Data Derivation Language
7. Which command is used for cleaning
2. What does DML stand for? up the environment (sql with Python)?

(a) Different Mode Level (a) my.close (b) is.close


(b) Data Model Language (c) con.close (d) mycon.close
(c) Data Mode Lane
8. A relational database consists of a
(d) Data Manipulation Language collection of

3. The clause of SELECT query (a) Tables (b) Fields


allows us to select only those rows in the (c) Records (d) Keys
results that satisfy a specified condition.
9. What is the full form of DDL?
(a) where (b) from
(a) Dynamic Data Language
(c) having (d) like
(b) Detailed Data Language
4. Which of the following function is used (c) Data Definition Language
to FIND the largest value from the
(d) Data Derivation Language
given data in MYSQL?
(a) MAX () (b) MAXIMUM () 10. A(n) in a table represents a logical
(c) LARGEST () (d) BIG () relationship among a set of values.
(a) Attribute (b) Key
5. The data types CHAR (n) and
(c) Tuple (d) Entry
VARCHAR (n) are used to create
and types of string/text 11. Name the method which is used for
fields in a database. displaying only one resultset.
(a) Fixed, equal (b) Equal, variable (a) fetchmany (b) fetchno
(c) Fixed, variable (d) Variable, equal (c) fetchall (d) fetchone
87
12. Name the host name used for signing 17. Consider the following query
in the database. SELECT name FROM stu
(a) localhost WHERE subject LIKE '______ Computer
(b) localpost Science';
(c) localcost Which one of the following has to be added
(d) none of the above into the blank space to select the subject which
has Computer Science as its ending string?
13. A relational database consists of a
collection of (a) $ (b) _

(a) Tuples (b) Attributes (c) || (d) %


(c) Relations (d) Keys 18. Consider following SQL statement.
14. Which is the subset of SQL commands What type of statement is this?
used to manipulate database structure SELECT * FROM employee
including tables? (a) DML
(a) Data Definition Language (DDL) (b) DDL
(b) Data Manipulation Language (DML) (c) DCL
(c) Both (a) and (b) (d) Integrity constraint
(d) None
19. Which of the following function is not
15. The term is used to refer to a an aggregate function?
field in a table. (a) Round () (b) Sum()
(a) Attribute (b) Tuple (c) Count () (d) Avg ()
(c) Row (d) Instance
20. Pick the correct username used for
16. Consider the following table namely logging in database (sql with Python).
employee: (a) root (b) local
Employee_id Name Salary (c) directory (d) host
5001 Amit 60000
21. Aggregate functions can be used in the
5009 Sumit 45000
select list or the clause of a
5020 Arpit 70000
select statement.
Which of the names will not be displayed They cannot be used in a clause.
by the below given query? SELECT
(a) Where, having
name FROM employee W HERE
employee_id>5009; (b) Having, where
(a) Amit, Sumit (b) Sumit, Arpit (c) Group by, having
(c) Arpit (d) Amit, Arpit (d) Group by, where
88
22. Select correct SQL query from below 27. Which of the following sublanguages
to find the temperature in increasing of SQL is used to query information
order of all cites. from the data base and to insert tuples
(a) SELECT city FROM weather into, delete tuples from, and modify
ORDER BY temperature; tuples in the database?
(b) SELECT city, temperature FROM (a) DML (Data Manipulation Language)
weather; (b) DDL (Data Definition Language)
(c) SELECT city, temperature FROM (c) Query
weather ORDER BY temperature; (d) Relational Schema
(d) SELECT city, temperature FROM
28. Which operator performs pattern
weather ORDER BY city;
matching?
23. In SQL, which command is used to (a) BETWEEN operator
SELECT only one copy of each set of
(b) LIKE operator
duplicable rows
(c) EXISTS operator
(a) SELECT DISTINCT
(d) None of these
(b) SELECT UNIQUE
(c) SELECT DIFFERENT 29. Which of the following is not a legal
(d) All of the above method for fetching records from
database from within Python?
24. Which of the following is a SQL
(a) fetchone()
aggregate function?
(a) LEFT (b) AVG (b) fetchtwo()

(c) JOIN (d) LEN (c) fetchall()


(d) fetchmany()
25. The command used for modifying the
records is: 30. By default, ORDER BY clause lists the
(a) update results in _______ order.
(b) add (a) Descending (b) Any
(c) updateall (c) Same (d) Ascending
(d) none of the above
31. Which of the following attributes can
26. An attribute in a relation is foreign key be considered as a choice for primary
if it is the ____key in any other relation. key?
(a) Candidate (b) Primary (a) Name (b) Street
(c) Super (d) Sub (c) Roll No. (d) Subject

89
32. In the given query which keyword has 36. Consider the following query:
to be inserted? SELECT name, instructor name, course
INSERT INTO employee______(1002, ______ id FROM instructor;
"Kausar", 2000); To display the field heading course with a
different heading as id, which keyword
(a) Table (b) Values
must be used here to rename the field name?
(c) Relation (d) Field
(a) From (b) Rename
33. What SQL statement do we use to (c) As (d) Join
display the record of all students
37. With SQL, how do you select all the
whose last name contains 5 letters
records from a table named
ending with "A"?
"Students" where the value of the
(a) SELECT * FROM STUDENTS column "FirstName" ends with an "a"?
WHERE LNAME LIKE ' A'; (a) SELECT * FROM Students WHERE
(b) SELECT * FROM STUDENTS FirstName ='a'
WHERE LNAME LIKE ' '; (b) SELECT * FROM Students WHERE
(c) SELECT * FROM STUDENTS FirstName LIKE 'a%'
WHERE LNAME LIKE ' ????A'; (c) SELECT * FROM Students WHERE
(d) SELECT * FROM STUDENTS FirstName LIKE '%a'
WHERE LNAME LIKE '*A'; (d) SELECT * FROM Students WHERE
FirstName ='%a%'
34. Consider the table with structure as:
Student (ID, name, dept name, 38. The HAVING clause does which of the
tot_cred) In the above table, which following?
attribute will form the primary key? (a) Acts EXACTLY like WHERE clause
(a) Name (b) Dept (b) Acts like a WHERE clause but is used
(c) total_credits (d) ID for columns rather than groups
(c) Acts like a WHERE clause but is used
35. Which of the following will you use in form groups rather than rows
the following query to display the
(d) Acts like a WHERE clause but is used
unique values of the column
for rows rather than columns.
dept_name?
SELECT __ dept_name FROM Company; 39. Which clause is used with "aggregate
functions"?
(a) All (b) From
(a) GROUP BY (b) SELECT
(c) Distinct (d) Name
(c) WHERE (d) Both (a) and (b)
90
40. To open a connector to MySql database, 44. SQL applies conditions on the groups
which statement is used to connect through clause after groups
with mysql? have been formed,

(a) Connector (b) Connect (a) Group by (b) With


(c) Where (d) Having
(c) password (d) username
45. To execute all the rows from the result
41. If column "Marks" contains the data
set, which method is used?
set {25, 35, 25, 35, 38},
(a) fetchall (b) fetchone
What will be the output after the
execution of the given query? (c) fetchmany (d) none of the above

SELECT MARKS (DISTINCT) FROM 46. What is the meaning of "HAVING"


STUDENTS; clause is SELECT query?
(a) 25. 35. 25. 35. 38 (a) To filter out the summary groups
(b) 25, 25, 35, 35 (b) To filter out the column groups

(c) 25, 35, 38 (c) To filter out the row and column values

(d) 25, 25, 35, 35 (d) None of the mentioned

42. Which connector is used for linking the 47. Which of the following queries
contains an error?
database with Python code?
(a) Select * from emp where empid =
(a) MySQL-connector
10003;
(b) YesSQL: connector
(b) Select empid from emp where empid
(c) PostSQL: connector = 10006;
(d) None of the above (c) Select empid from emp;
(d) Select empid where empid=1009 and
43. If column "Salary" contains the data
lastname='GUPTA';
set {1000, 15000, 25000, 10000, 15000},
What will be the output after the execution 48. Which operator tests column for the
absence of data (i.e., NULL value) ?
of the given query?
SELECT SUM (DISTINCT SALARY) (a) EXISTS operator
FROM EMPLOYEE; (b) NOT operator

(a) 75000 (b) 25000 (c) IS operator

(c) 10000 (d) 50000 (d) None of these

91
49. Consider the following query: 54. Which of the following group functions
SELECT name FROM class WHERE ignore NULL values?
subject_____NULL; (a) MAX (b) COUNT
Which comparison operator may be used (c) SUM (d) All of the above
to fill the blank space in above query?
55. What will be the order of the data being
(a) = (b) LIKE
sorted after the execution of given
(c) IS/IS Not (d) if query SELECT * FROM STUDENT
ORDER BY ROLL_NO;
50. Which SQL function is used to count
the number of rows in a SQL query? (a) Custom Sort

(a) COUNT () (b) NUMBER () (b) Descending

(c) SUM () (d) COUNT (*) (c) Ascending


(d) None of the above
51. With SQL, how can you return the
number of not null record in the Project 56. Where and Having clauses can be
field of "Students" table? used interchangeably in SELECT
(a) SELECT COUNT (Project) FROM queries?
Students (a) True (b) False

(b) SELECT COLUMNS (Project) FROM (c) Only in views (d) With order by
Students
57. A is property of the entire relation,
(c) SELECT COLUMNS (*) FROM which ensures through its value that
Students each tuple is unique in a relation.
(d) SELECT COUNT (*) FROM Students (a) Rows (b) Key

52. Which of the following is not an (c) Attribute (d) fields


aggregate function?
58. The operation whose result contains
(a) Avg (b) Sum all pairs of tuples from the two
(c) With (d) Min relations, regardless of whether their
attribute values match.
53. All aggregate functions except ____
ignore null values in their input (a) Join
collection. (b) Cartesian product
(a) Count (attribute) (b) Count (*) (c) Intersection
(c) Avg (d) Sum (d) Set difference
92
59. Consider following SQL statement. 60. The pattern ' ' matches any string
What type of statement is this? of three character. ' %'
CREATE TABLE employee (name matches any string of three
VARCHAR, id INTEGER) characters.
(a) DML (a) Atleast, Exactly
(b) DDL (b) Exactly, Atleast
(c) DCL (c) Atleast, All
(d) Integrity constraint (d) All, Exactly

ANSWER KEYS
1 (a) 21 (b) 41 (c)
2 (d) 22 (d) 42 (a)
3 (a) 23 (a) 43 (d)
4 (a) 24 (b) 44 (d)
5 (c) 25 (a) 45 (a)
6 (b) 26 (b) 46 (a)
7 (d) 27 (a) 47 (d)
8 (a) 28 (b) 48 (c)
9 (c) 29 (b) 49 (c)
10 (c) 30 (d) 50 (d)
11 (d) 31 (c) 51 (a)
12 (a) 32 (b) 52 (c)
13 (c) 33 (a) 53 (b)
14 (b) 34 (d) 54 (d)
15 (a) 35 (c) 55 (c)
16 (a) 36 (c) 56 (b)
17 (d) 37 (c) 57 (b)
18 (a) 38 (c) 58 (b)
19 (a) 39 (a) 59 (b)
20 (a) 40 (b) 60 (b)
93
SET - II
1. The degree of a relation is the number 8. Types of SQL Commands are -
of _____ it contains. (a) DDL (b) DML
(a) Records (b) Keys (c) DCL (d) All of the above
(c) Attributes (d) Relations
9. Full form of DDL is -
2. In database system ______ key is used
to identify tuples uniquely in a relation. (a) Data Describe Language

(a) Primary key (b) Secondary key (b) Definition Data Language

(c) Internal key (d) Foreign key (c) Data Definition Language

3. The Cardinality of a relation is the (d) Data Distinct Language


number of ________ it contains. 10. Commands that comes under DDL is/
(a) Records (b) Keys are -
(c) Attributes (d) Relations (a) CREATE (b) DROP
4. A _______is the reference key between (c) TRUNCATE (d) All of the above
two tables.
(a) Primary key (b) Candidate key 11. Full form of DML is -

(c) Foreign key (d) Super key (a) Data Multiplication Language

5. COMMIT & ROLLBACK are (b) Data Manipulation Language


statements. (c ) Data Modify Language
(a) DDL (b) DML (d) Data Mapping Language
(c) DCL (d) TCL
12. Which of the following is/are TRUE
6. GRANT and REVOKE are about DDL command?
statements.
(a) Our data is stored in a table that is
(a) DDL (b) DML
described by the schema, thus DDL
(c) DCL (d) TCL commands deal with the schema.
7. The SYSDATE () function returns the (b) W ith the DDL commands, any
current date and time in the format . structural changes can be made to the
(a) YY-MM-DD HH:MM:SS table, including creation, deletion, and
(b) DD-MM-YYYY HH:MM:SS alteration.
(c) YYYY-MM-DD HH:MM:SS (c) Both (a) and (b)
(d) None of these (d) None of the above

94
13. Command that comes under DML is/ 17. Full form of TCL is -
are - (a) Transaction Common Language
(a) ROLLBACK (b) GRANT
(b) Transaction Commit Language
(c) UPDATE (d) All of the above
(c) Transaction Concatenate Language
14. Select the correct statement.
(d) Transaction Control Language
(a) W ith the DDL commands, any
18. Commands that come under TCL is/are -
structural changes can be made to the
table, including creation, deletion and (a) COMMIT
alteration. (b) ROLLBACK
(b) W ith the DML commands, any (c) SAVEPOINT
structural changes can be made to the
(d) All of the above
table, including creation, deletion, and
alteration. 19. What is TRUE about SAVEPOINT?
(c) W ith the DCL commands, any (a) Following the completion of a
structural changes can be made to the transaction, it must be executed to
table, including creation, deletion, and save all the operations performed in
alteration. the transaction.
(d) With the TCL commands, any structural (b) A transaction can be rolled back to its
changes can be made to the table, last saved state.
including creation, deletion, and
(c) A specific part of a transaction can be
alteration.
given a name.
15. Full form of DCL is - (d) None of the above
(a) Data Control Language
20. Following the completion of a
(b) Data Commit Language
transaction, it must be executed to
(c) Data Common Language save all the operations performed in
(d) Data Concatenate Language the transaction. Here we are talking
about which command?
16. Command that comes under DCL is/are -
(a) GRANT (a) REVOKE

(b) REVOKE (b) COMMIT

(c) Both (a) and (b) (c) ROLLBACK


(d) None of the above (d) SAVE

95
21. Difference between GRAND & 24. Which command use to delete data
REVOKE command is/are? from a table?
(a) The GRANT command can be used to (a) REMOVE (b) DELETE
grant a user access to databases and (c) DROP (d) None of these
tables whereas the REVOKE command
25. Which command is use to delete a table?
can be used to revoke all access
privileges already assigned to the user. (a) REMOVE (b) DELETE

(b) The REVOKE command can be used (c) DROP (d) None of these
to grant a user access to databases 26. Which of the following is TRUE about
and tables whereas The GRANT TCL?
command can be used to revoke all
(a) Transactions can be saved to the
access privileges already assigned to
database and rolled back with the help
the user.
of TCL commands in SQL.
(c) A transaction can be rolled back to its
(b) There will be certain privileges that
last saved state.
each user has; consequently, the data
(d) None of the above can be accessed by them using TCL.
22. Which of the following statement(s) is/ (c) Our data is stored in a table that is
are TRUE about DCL? described by the schema, thus TCL
(a) The DCL commands in SQL allow us commands deal with the schema.
to control which users have access to (d) SQL TCL commands can be used to
the data stored in SQL tables. perform any kind of retrieval or
(b) There will be certain privileges that manipulation of the data present in
each user has; consequently, the data SQL tables.
can be accessed by them. 27. Which is/are the OPTIONAL Clause in
(c) The DCL commands in SQL allow us SELECT statement?
to grant privileges to a user on the SQL (a) WHERE (b) ORDER BY
database and its table(s), or revoke
(c) HAVING (d) All of these
privileges that have already been
granted. 28. Which statement is TRUE about the
(d) All of the above WHERE Clause?
(a) In order to retrieve rows, WHERE
23. The table records can be retrieved
Clause is used.
using which command?
(b) In order to group the rows, WHERE
(a) RETRIEVE (b) SELECT
Clause is used.
(c) CREATE (d) ALTER
96
(c) In order to select the defined groups, 32. Which of the following clause cannot
WHERE Clause is used. be optional in SQL SELECT Statement?
(d) In order to return the rows, WHERE (a) WHERE (b) GROUP BY
Clause is used. (c) ORDER BY (d) None of the above
29. Which statement is TRUE about the
33. Which of the following clause is
GROUP BY Clause?
optional in SQL SELECT Statement?
(a) In order to retrieve rows, GROUP BY
(a) SELECT (b) FROM
Clause is used.
(c) HAVING (d) None of the above
(b) In order to group the rows that share
the same property, GROUP BY Clause 34. Which clause is used to retrieve a
is used. unique element from the table?
(c) In order to select the defined groups, (a) SELECT UNIQUE
GROUP BY Clause is used. (b) SELECT DISTINCT
(d) In order to return the rows, GROUP BY (c) Both (a) and (b)
Clause is used. (d) None of the above
30. Which statement is TRUE about the
35. What is the functionality of SQL COUNT?
HAVING Clause?
(a) It returns the number of record of table
(a) In order to group the rows, HAVING
Clause is used. (b) It returns the number of record of
database
(b) In order to return the rows, HAVING
Clause is used. (c) It returns the no of record of row

(c) In order to select the defined groups (d) It returns the no of record of column
by the GROUP BY Clause, HAVING 36. In SQL SELECT COUNT, one needs to
Clause is used. specify the -
(d) None of the above (a) Column Name
31. Which statement is TRUE about the (b) Row Name
ORDER BY Clause?
(c) Table Name
(a) In order to return the rows in a specific
(d) None of the above
order, ORDER BY Clause is used.
37. Using the SQL first() function, one can
(b) In order to group the rows, ORDER BY
return the ____ value of the selected
Clause is used.
column.
(c) In order to select the defined groups,
ORDER BY Clause is used. (a) First (b) Second

(d) None of the above (c) Third (d) Last


97
38. Which function combines the two 43. What is the keyword of the Ascending
different columns? and Descending?
(a) ADD (b) MERGE (a) ASCE, DESC (b) ASC, DES
(c) CONCAT (d) None of the above (c) ASCE, DES (d) ASC, DESC
39. What is the difference between 44. SQL INSERT is used to insert a -
HAVING and WHERE clause?
(a) Single or Multiple records
(a) HAVING clause is used in column
(b) Single or Multiple databases
operation whereas WHERE clause is
(c) Single or Multiple tables
used in row operation.
(b) HAVING clause is post-filter whereas (d) None of the above
WHERE clause is pre-filter. 45. In order to insert a row directly in the
(c) HAVING clause filters the groups table, which command is used?
whereas WHERE clauses filter the (a) INSERT IN
single record of the table. (b) INSERT INSIDE
(d) All of the above (c) INSERT UNDER
40. What is the difference between MIN (d) INSERT INTO
and MAX function? 46. What is the clause to delete all rows
(a) MIN function is used to show the from the table?
minimum data and MAX function is
(a) SQL DELETE ALL ROW S
used to show the maximum data.
Table_Name;
(b) MIN function is used to show the
(b) SQL DELETE ROWS Table_Name;
maximum data and MAX function is
used to show the minimum data. (c) DELETE FROM ALL ROW S
Table_Name;
(c) Both of the above
(d) DELETE FROM Table_Name;
(d) None of the above
41. In order to sort the records according 47. In order to delete duplicate rows from
to the columns, which clause is used? the table, which keyword is used?

(a) HAVING (b) GROUP BY (a) DELETE (b) DISTINCT

(c) ORDER BY (d) None of the above (c) FROM (d) WHERE
42. By default, sorting by ORDER BY 48. In order to delete the database, which
clause is done in which order? keyword is used?
(a) Ascending (b) Descending (a) DROP (b) DELETE
(c ) Both (a) and (b) (d) None of these (c) ALTER (d) None of the above

98
49. Which SQL function is used to count 54. What is the purpose of the SQL AS
the number of rows in a SQL query? clause?

(a) COUNT () (b) NUMBER () (a) The AS SQL clause is used to change
the name of a column in the result set
(c) SUM () (d) COUNT (*)
or to assign a name to a derived
50. Which SQL keyword is used to retrieve column
a maximum value? (b) The AS clause is used with the JOIN
(a) MOST (b) TOP clause only

(c) MAX (d) UPPER (c) The AS clause defines a search


condition
51. ___ is not a category of SQL command.
(d) All of the mentioned
(a) TCL (b) SCL
55. Which of the following is a legal
(c) DCL (d) DDL
expression in SQL?
52. If you don't specify ASC or DESC after (a) SELECT NULL FROM SALES;
a SQL ORDER BY clause, the following
(b) SELECT NAME FROM SALES;
is used by default ____
(c) SELECT * FROM SALES WHEN
(a) ASC (b) DESC
PRICE = NULL;
(c) There is no default value
(d) SELECT # FROM SALES;
(d) None of the mentioned
56. DCL provides commands to perform
53. Which of the following statement is actions like
true? (a) Change the structure of Tables
(a) DELETE does not free the space (b) Insert, Update or Delete Records and
containing the table and TRUNCATE Values
free the space containing the table
(c) Authorizing Access and other control
(b) Both DELETE and TRUNCATE free over Database
the space containing the table (d) None of Above
(c) Both DELETE and TRUNCATE does 57. Which of the following command
not free the space containing the table makes the updates performed by the
(d) DELETE free the space containing the transaction permanent in the database?
table and TRUNCATE does not free (a) ROLLBACK (b) COMMIT
the space containing the table (c) TRUNCATE (d) DELETE
99
ANSWER KEYS
1. (c) 16. (c) 31. (a) 46. (d)

2. (a) 17. (d) 32. (d) 47. (b)

3. (a) 18. (d) 33. (c) 48. (a)

4. (c) 19. (c) 34. (c) 49. (d)

5. (d) 20. (b) 35. (a) 50. (c)

6. (c) 21. (a) 36. (a) 51. (b)

7. (c) 22. (d) 37. (a) 52. (a)

8. (d) 23. (b) 38. (c) 53. (a)

9. (c) 24. (b) 39. (d) 54. (a)

10. (d) 25. (c) 40. (a) 55. (b)

11. (b) 26. (a) 41. (c) 56. (c)

12. (c) 27. (d) 42. (a) 57. (b)

13. (c) 28. (a) 43. (d)

14. (a) 29. (b) 44. (a)

15. (a) 30. (c) 45. (d)

100
Fill in the Blanks

1. SQL stands for _______ Query Language. 13. The SQL built-in function ________ totals
2. A connectivity package such as _______ values in numeric columns.

must be imported before writing database 14. The SQL built-in function _________
connectivity Python code. obtains the largest value in a numeric
column.
3. The SQL keyword_______ is used to
15. The SQL built-in function _________
specify the table(s) that contains the data
obtains the smallest value in a numeric
to be retrieved.
column.
4. To remove duplicate rows from the result
16. The SQL built-in function __________
of a query, specify the SQL qualifier
computes the number of rows in a table.
________ in select list.
17. The SELECT clause _________ is used
5. To obtain all columns, use a(n) _________ to collect those rows that have the same
instead of listing all the column names in value in a specified column.
the select list.
18. _____________ method returns the result
6. The SQL _______ clause contains the set in the form of tuples containing the
condition that specifies which rows are to records or rows returned by the sql table.
the selected. 19. A session between the application
7. To sort the rows of the result table, the program and the database is called
________ clause is specified. _________

8. Columns can be sorted in descending 20. A __________ query is used to check if


data has been added to the table or not.
sequence by using the SQL keyword ____
21. The ______________ function works with
9. When two conditions must both be true for
data of multiple rows at a time and returns
the rows to be selected, the conditions are
aggregated value.
separated by the SQL keyword ________
22. The _____ clause lets you arrange the
10. To refer to a set of values needed for a result set in the order of single column,
condition, we can use the SQL operation multiple column and custom sort order too.
_____
23. To specify filtering condition for groups, the
11. To exclude one or more values (a list of ________ clause is used in MYSQL.
values) using a condition, the SQL keyword 24. By default, the ORDER BY clauses sorts
________ ________ should be used. the result set in the ________ order.
12. The SQL keyword _______ is used in SQL 25. To sort the result set in descending order,
expressions to select based on patterns. ______ keyword is used with ORDER BY.
101
ANSWER KEYS
1. Structured 14. MAX

2. Mysql.connector 15. MIN

3. FROM 16. COUNT

4. DISTINCT 17. GROUP BY

5. Asterisk (*) 18. Fetchall()

6. WHERE 19. Connection

7. ORDER BY 20. Select

8. DESC 21. Group/row/ aggregation function

9. AND 22. ORDER BY

10. IN 23. Having

11. NOT IN 24. Ascending

12. LIKE 25. DESC

13. SUM

102
True/False Questions

1. The condition in a WHERE clause in a 12. ORDER BY can be combined with the
SELECT query can refer to only one value SELECT statement.
2. SQL provides the AS keyword, which can 13. Data manipulation language (DML)
be used to assign meaningful column
commands are used to define a database,
names to the results of queries using the
including creating, altering, and dropping
SQL built-in functions.
tables and establishing constraints.
3. The rows of the result relation produced by
a SELECT statement can be sorted but 14. The keyword LIKE can be used in a
only by one column. WHERE clause to refer to a range of
values.
4. SQL is a programming language.
5. SELECT DISTINCT is used if a user wishes 15. The SQL keyword GROUP BY instructs the
to see duplicate columns in a query. DBMS to group together those rows that
have the same value in a column.
6. The HAVING clause acts like a WHERE
clause, but it identifies groups that meet a 16. The keyword BETWEEN can be used in a
criterion, rather than rows. WHERE clause to refer to a range of
7. The qualifier DISTINCT must be used in values.
an SQL statement when we want to 17. Read operation on any table means to
Eliminate duplicate rows.
fetch some useful information from the
8. DISTINCT and its counterpart, ALL, can be table.
used more than once in a SELECT
18. Use fetchall() method to retrieve only one
statement.
value from a database table.
9. DISTINCT and its counterpart, ALL, can be
used together on single field in a SELECT 19. Row count is a read-only attribute.
statement. 20. To disconnect database connection, use
10. SUM, AVG, MIN and MAX can only be used connect () method.
with numeric columns
21. Update statement is used to insert data
11. The SQL statement: SELECT salary + into the table.
Comm AS Total FROM Emp; adds two
22. The ORDER BY clause combines all those
fields salary and comm from each row
together and lists the results in a column records that have identical values in a
named Total. particular field or a group of fields.

103
23. The WHERE clause is used to specify 27. The return value of MAX () function is a
filtering conditions for groups. numeric value.
24. DISTINCT option causes a group function 28. Multiple row function is also known as
to consider only the unique values of the scalar function
argument expression. 25. By default, 29. SUM () function is used to count the total
ORDER BY clause sorts the result set in number of records in a table.
descending order.
30. Argument type of AVG () function can be
26. COUNT () function ignores duplicate and numeric or string data type.
null values while counting the records.

ANSWER KEYS
1. False 16. True

2. True 17. True

3. False 18. False

4. False 19. True

5. False 20. False

6. True 21. False

7. True 22. False

8. False 23. False

9. False 24. True

10. True 25. False

11. True 26. True

12. True 27. True

13. False 28. False

14. False 29. False

15. True 30. False

104
Very Short Answer Type Questions (1 mark)

1. Name the command/clause which is used 14. What is max () function in SQL?
to display the records in ascending or
15. W hat do you mean by degree and
descending order.
cardinality of table?
2. Give example of any two DML commands.
16. Expand DDL and DML
3. What is the purpose of SQL?
17. Which command is used to increase the
4. What is primary key? salary of workers in table salary? (Update
/ Alter)
5. Which command is used to display a list
of already existing tables? 18. Name the command used to see the
structure of table.
6. Which command is used to change the
structure of table? 19. Which aggregate function is used to find
sum of column in a table?
7. Which command is used to change the
data of the table? 20. What is the difference between having and
where clause?
8. Which command is used to delete data of
the table? 21. Name an aggregate function in SQL which
return the average of numeric values.
9. Which command delete the structure of
table? 22. What is the use of "like" in SQL?

10. Identify the DDL and DML commands from 23. Correct the following statement: Delete
the following: Create, Delete table data;

11. Which clause is used with aggregate 24. What do you mean by aggregate function?
functions? (Group by/ Where)
25. Write two wild card characters which are
12. What do you mean by candidate key? used with like operator?

13. Correct the error in the following query. 26. Duplication of record is called ________
Select * from RECORD where Rname =
27. What is the difference between char and
%math%;
varchar?

105
ANSWER KEYS
1. order by clause 15. Number of columns in table is called
degree. Number of rows in a table is called
2. Insert, Delete
cardinality.
3. SQL is structured query language. It is a 16. DDL - Data Definition Language, DML -
standard language of all the RDBMS Data Manipulation Language.
4. A field which is unique for each and every 17. Update
record in table is called primary key.
18. Desc
5. show tables; 19. sum()

6. Alter 20. Having clause can be used with group by


clause while where clause can be used
7. Update
without group by clause.
8. Delete 21. avg()

9. Drop 22. "Like" operator is used to match a


particular pattern in a particular column in
10. Create -DDL and Delete --DML
SQL.
11. Group by 23. Delete from data

12. Those fields which can act as primary key 24. A function which perform calculation on
is called candidate key multiple values and return single value

13. Select * from RECORD where Rname like 25. % and underscore( _ )
%math%; 26. Redundancy

14. It returns the largest value from a particular 27. Char is fixed length data type and varchar
column. is variable length data type

106
Short Answer Type Questions (2 marks)
1. What is the difference between cardinality 7. What do you mean by domain of an
and degree? attribute in DBMS? Explain with an
example.
2. Differentiate between W HERE and
HAVING clause. 8. Differentiate between fetchone() and
fetchmany() methods with suitable
3. Define Primary Key of a relation in SQL.
examples.
Give an Example using a dummy table.
9. What is Constraint? Give example of any
4. Consider the following Python code is two constraints.
written to access the record of CODE
10. Write the steps to perform an Insert query
passed to function: Complete the missing
in database connectivity application.
statements:
Table 'student' values are rollno, name, age
def Search(eno):
(10,'Ashok',26)
#Assume basic setup import, connection
11. Define Candidate Key and Alternate Key
and cursor is created with suitable examples from a table
query="select * from emp where containing some meaningful data.
empno=________".format(eno) 12. Define RDBMS. Name any two RDBMS
mycursor.execute(query) software.

results = mycursor._________ 13. What is the purpose of the following


clauses in a select statement?
print(results)
i) ORDER BY ii) HAVING
5. Differentiate between DDL and DML with
14. Write SQL queries for the following:
one Example each.
i. Create the table Product with
6. Answer the following: appropriate data types and constraints.
i) Name the package for connecting ii. Identify the primary key in Product.
Python with MySQL database. 15. Write any two differences between Single_
ii) What is the purpose of cursor object? row functions and Aggregate functions.

107
ANSWER KEYS
1. Degree - The number of attributes or 5. DDL- Data definition language. Consists
columns in a relation is called the Degree of commands used to modify the metadata
of the relation. of a table. For Example- create table, alter
Cardinality - The number of tuples/ rows table, drop table DML-Data manipulation
in a relation is called the Cardinality of the language. Consist of commands used to
relation. modify the data of a table. For Example-
insert, delete, update
2. WHERE clause is used to select particular
rows that satisfy a condition whereas 6. i) import mysql.connector
HAVING clause is used in connection with ii) It is the object that helps to execute
the aggregate function, GROUP BY clause. the SQL queries and facilitate row by
For ex. - row processing of records in the
select * from student where marks > 75; resultset.

This statement shall display the records for 7. Domain of an attribute is the set of values
all the students who have scored more than from which a value may come in a column.
75 marks. On the contrary, the statement - E.g. Domain of section field may be
select * from student group by stream (A,B,C,D).
having marks > 75; shall display the 8. fetchone() is used to retrieve one record
records of all the students grouped at a time but fetchmany(n) will fetch n
together on the basis of stream but only records at a time from the table in the form
for those students who have scored marks of a tuple.
more than 75. 9. Constraints are the checking condition
3. Primary Key- one or more attribute of a which we apply on table to ensure the
relation used to uniquely identify each and correctness of data . Example primary key,
every tuple in the relation. For Example : In not null, default, unique etc
the below Table Student, RollNo can be the 10. import mysql.connector as mydb
Primary Key conn=mydb.connect(host="localhost",
RollNo Name Marks user="root", passwd="1234")
01 Aru 95 cur=conn.cursor()
cur.execute("INSERT INTO student
02 Rubi 85
values(10,'Ashok',26);")
4. { } and fetchone()
cur.commit()
108
11. A table may have more than one such 13. i) Order By : This clause is used to
attribute/group of attributes that identifies arrange the records in ascending or
a tuple uniquely, all such attribute(s) are descending order.
known as Candidate Keys. All the
Example: Select * from book order
candidate key except primary key are
by price;
called Alternate key.
Table: Employee (empno, aadhar_no, ii) Having : HAVING Clause in SQL is
voter_id, ename, deptno, sal, city) used to specify conditions on the
rows with GROUP BY clause.
In the above table Employee: empno, aadhar_
no, voter_id all are candidate key. If we Example: Select sum(price) from
define empno as primary key then remaining book group by (subject) having price
candidate keys will be alternate key. > 100;
12. RDBMS stands for Relational Database 14. i) Create table product (Pcode
Management System. It is a program that varchar(3) not null Primary key,
offers commands to create, update, and PName Varchar(20), UPrice int(4),
manage the data with multiple tables.
Manufacture Varchar(20));
Examples of RDBMS are 1. MySQL
ii) Pcode is primary key.
2. Oracle 3. Microsoft SQL Server.

15.

Single row Functions Multiple row functions/ Aggregate Functions


It operates on a single row at a time It operates on multiple rows.
It returns one result per row It returns one result for multiple rows

It can be used in Select, Where, and It can be used in the select clause only.
Order by clause. Max(), Min(), Avg(), Sum(), Count() and
Math, String and Date functions are Count(*) are examples of multiple
examples of single row functions
row functions

109
Long Type Questions

1. What is database? What are the advantages and disadvantages of using database?

2. What is Key? Explain primary key, candidate key, alternate key and foreign key with example.

3. What is SQL? What are different categories of commands available in SQL?

4. What is SQL? Discuss DCL and DML commands with examples

5. Differentiate between DDL and DML commands.

6. Differentiate between CHAR and VARCHAR data types.

7. (a) Which key word is used to sort the records of a table in descending order?

(b) Which command is used to modify the records of the table?

(c) Which clause is used to remove the duplicate rows of the table?

(d) Differentiate between Primary key and Candidate key,

(e) Differentiate between Degree and Cardinality key.

8. Explain Aggregate functions of SQL with examples.

9. Discuss connecting SQL with Python.

10. (a) Write two examples of DBMS software.

(b) What is meant by NULL value in MySQL?

(c) Table 'Club' has 4 rows and 3 columns. Table 'Member' has 2 rows and 5 columns. What will
be the cardinality of the Cartesian product of them?

11. The SQL SELECT provides clauses for sorting data and for summarizing results. Write the
names of clauses for these.

12. What are aggregate functions? What is their use? Give some examples.

13. What are different types of SQL functions?

14. What is the significance of GROUP BY clause in a SQL query?

15. What type of functions can you use with GROUP BY and HAVING clauses?

16. What is the difference between a WHERE clause and a HAVING clause of SQL SELECT
statement?
110
PRACTICE SET
PART - A
Select the most appropriate option out of the options given for each question.

1. If a user tries to remove an element 5. In computer, converting a digital signal


from empty Stack, it is called in to an analog signal is called
(a) Empty Collection (a) modulation
(b) Overflow (b) demodulation
(c) Underflow (c) conversion
(d) Garbage Collection
(d) transformation
2. Which of the following is application
6. Which of the following keywords will
of Stack?
you use in the following query to
(a) One Way Traffic display the unique values of the
(b) A line of ticket seeking people column dept_name?
(c) Reversing the order of items (a) all (b) from
(d) Printer shared among four computers (c) distinct (d) unique
3. Consider the following operation
7. The pattern '___' matches any string
performed on a stack of size 5. of _____ three characters. '___%'
Push(1); Pop();Push(2);Push(3); Pop(); matches and string of _________ three
Push(4);Pop();Pop();Push(5); characters.
After the completion of all operation, the (a) Atleast, Exactly
numbers of elements present in stack are:
(b) Exactly, Atleast
(a) 1 (b) 2
(c) Atleast, All
(c) 3 (d) 4
(d) All, Exactly
4. Network in which every computer is
capable of playing the role of a client, 8. All aggregate functions except _______
or a server or both at same time is called ignore null values in their input collection.

(a) local area network (a) count(attribute)

(b) peer-to-peer network (b) count(*)


(c) dedicated server network (c) avg
(d) wide area network (d) none of these

111
PART - B
SECTION - 1

9. Expand the following- 11. Give difference between CHAR and

i. SMTP ii. DHCP VARCHAR. Give Example.

iii. HTTP iv. TCP 12. What do you understand by the terms
Candidate Key? What is Cardinality?
10. Define Web-Hosting?
13. The SQL SELECT provides clauses for
OR
sorting data and for grouping results.
Give difference between Video
Write the names of clauses for these.
Conferencing and Chat.
SECTION - 2

14. Each node of a Stack contains the following (i) Karan wants to remove all the data from
information: PINCODE and NAME of city. table W ORKER from the database
Write a PUSHCITY() function to implement department.
push on stack like operation to add a node Which command will he use from the
to Stack. following?
OR a) DELETE FROM WORKER;
Write a POPCITY() function to implement
b) DROP TABLE WORKER;
pop from stack like operation to remove a
node (same as above) from Stack. c) DROP DATABASE Department;
d) DELETE * FROM WORKER;
15. A department is considering maintaining
their worker data using SQL to stroe the (ii) Identify the attribute best suitable to be
data. As a Database Administrator, Karan declared as a primary key.
has decided that: Name of the database - (iii) Karan wants to increase the size of the
Department Name of the table -Worker The FIRST_NAME column from 10 to 20
attributes of Worker are as follows: characters.
WORKER_ID - CHARACTER OF SIZE 3 Write an appropriate query to change the
FIRST_NAME-CHARACTER OF SIZE 10 size.
LAST_NAME - CHARACTER OF SIZE 10
(iv) Write a query to display the structure of the
SALARY - NUMERIC
table Worker, i.e. name of the attribute and
JOINING_DATE - DATE their respective data types.
112
ANSWER KEYS
Part-A 12. CANDIDATE KEY A Candidate key is the
1. c) UNDERFLOW one that is capable of becoming primary
2. c) Reversing the order of items 1 key. CARDINALITY OF A RELATION
Cardinality of a relation represents number
3. a) 1
of rows in the relation.
4 b) peer-to-peer network
5. a) modulation 13. ORDER BY for sorting GROUP BY for
grouping data
6. c) distinct
14. city=[]
7. b) Exactly, Atleast
8. a) count(attribute) def PUSHCITY(cityname,pincode):

city.insert(0,[cityname,pincode])
Part - B
9. Expand the following- OR
i. SIMPLE MAIL TRANSFER PROTOCOL city=[]
ii. DYNAMIC HOST CONFIGURATION
def POPCITY():
PROTOCOL
if len(city)==0:
iii. HYPERTEXT TRANSFER PROTOCOL
iv. TRANSMISSION CONTROL PROTOCOL print("Underflow")
10. When a hosting provider allocates space return None
on a web server for a website to store its
return city.pop()
files, they are hosting a website. OR
Video Conferencing Chat Audio as well 15. (i) d) DELETE * FROM WORKER;
Visuals are shared only text (ii) WORKER_ID
communicated. High Bandwidth required
(iii) ALTER TABLE WORKER MODIFY
Works with low bandwidth also.
FIRST_NAME VARCHAR(20)
11. CHAR is used to occupy fixed memory
(iv) DESC W ORKER/DESCRIBE
irrespective of the actual values but
WORKER
VARCHAR uses only that much memory
which is used actually for the entered
values. E.g. CHAR(10) will occupy always
10 bytes in memory no matter how many
characters are used in values. But
VARCHAR will uses only that much bytes
of memory whose values are passed.

113

You might also like