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

12 – Computer Science

67. A sequence of characters surrounded by quotes is called


a) Character b) String c) Literal d) Word
68. The value with triple-quote is used to give
a) Number b) Floating Point
c) Complex numbers d) Multi line string
69. A Boolean literal can have any of
a) Only one value b) Two values c) Three vales d) Four values
70. In Python, which of the special character is also called as escape sequence character?
a) \ b) / c) // d) \\
71. Escape sequence used for new line character is
a) \t b) \r c) \l d) \n
72. The output for the following line is
print(“\” Python \””)
a) Python b) ‘Python’ c) “Python” d) “’ Python”’
73. Which of the following is an example for Long integer data type?
a) O102 b) OX102 c) 102L d) 102
74. Which of the following is made up of two floating point values, one each for the real
and imaginary parts?
a) Complex b) Float
c) Integer d) None of these
75. Which of the following is enclosed with single or double or triple quotes?
a) Numeric b) Strings
c) Float d) Boolean
II. Additional Two and Three Marks:
1. List the key features of Python.
✓ It is a general-purpose programming language which can be used for both
scientific and non-scientific programming.
✓ It is a platform independent programming language.
✓ The programs written in Python are easily readable and understandable.
2. What is literal? List its types.
Literal is a raw data given to a variable or constant. In Python, there are various
types of literals.
1) Numeric 2) String 3) Boolean
..145..
12 – Computer Science

3. What are the data types in Python?


Python Data types All data values in Python are objects and each object or value
has type. Python has Builtin or Fundamental data types such as Number, String,
Boolean, tuples, lists and dictionaries.
4. Write a note on comments in Python?
In Python, comments begin with hash symbol (#). The lines that begins with # are
considered as comments and ignored by the Python interpreter. Comments may be
single line or no multi-lines. The multiline comments should be enclosed within a set
of ''' '''(triple quotes) as given below.
# It is Single line Comment
''' It is multiline comment which contains more than one line '''
5. What are keywords? List some keywords.
Keywords are special words used by Python interpreter to recognize the structure
of program. As these words have specific meaning for interpreter, they cannot be
used for any other purpose.
Some keywords are
class return continue for del
lambda True def while if
6. What are operators and operands?
In computer programming languages operators are special symbols which
represent computations, conditional matching etc.
Value and variables when used with operator are known as operands.
7. Write about relational operators.
Relational or Comparative operators A Relational operator is also called as
Comparative operator which checks the relationship between two operands. If the
relation is true, it returns True; otherwise it returns False.
Operators:
==, >, <, >=, <=, !=
Example:
If a=10, b=10 then
✓ a==b returns False
✓ a>b returns True

..146..
12 – Computer Science

8. Write about logical operators.


In python, Logical operators are used to perform logical operations on the given
relational expressions. There are three logical operators they are and, or and not.
Example:
If a=90, b=30 then
✓ a>b or a==b returns True
✓ a>b and a==b returns False
9. What are delimiters?
Delimiters Python uses the symbols and symbol combinations as delimiters in
expressions, lists, dictionaries and strings. Following are the delimiters.
( ) [ ] { } , : . ‘ = ; += -= *= /= //= %= &= |= ^= >>= <<= **=
10. Write a note on the numeric data type in Python?
➢ The built-in number objects in Python supports integers, floating point numbers
and complex numbers.
➢ Integer Data can be decimal, octal or hexadecimal.
➢ Octal integer use digit 0 (Zero) followed by letter 'o' to denote octal digits and
hexadecimal integer use 0X and L to denote long integer.
➢ A floating-point data is represented by a sequence of decimal digits that includes
a decimal point.
➢ An Exponent data contains decimal digit part, decimal point, exponent part
followed by one or more digits.
➢ Complex number is made up of two floating point values, one each for the real
and imaginary parts.
Example:
102, 0o102, 0X876 34L, 156.23 and 12.E04
III. Additional Five Marks:
1. What is identifier? Write the rules using identifiers. Give example
Identifiers An Identifier is a name used to identify a variable, function, class,
module or object.
✓ An identifier must start with an alphabet (A..Z or a..z) or underscore ( _ ).
✓ Identifiers may contain digits (0 .. 9)
✓ Python identifiers are case sensitive i.e. uppercase and lowercase letters are
distinct.
..147..
12 – Computer Science

✓ Identifiers must not be a python keyword.


✓ Python does not allow punctuation character such as %,$, @ etc., within
identifiers.
Example of valid identifiers:
Sum, total_marks, regno, num1
Example of invalid identifiers:
12Name, name$, total-mark, continue

..148..
6. Control Structures

I. Additional One Marks:


1. The process of skipping a segment or set of statements and execute another segment
based on the test condition is
a) Sequential b) alternative c) iteration d) Looping
2. A set of statements executed for multiple times is called
a) Sequential b) alternative c) iteration d) All of these
3. A program statement that causes jump of control from one part of the program to
another is called
a) Control statements b) Control structures
c) Both a and b d) Looping structure
4. Which of the following are compound statements used to alter the control flow of the
process or program depending on the state of the process?
a) Control statements b) Control structures
c) Both a and b d) Looping structure
5. How many types of control structures are there?
a) 4 b) 3 c) 2 d) 1
6. A sequence of statements which are executed one after another is
a) Sequential b) alternative c) iteration d) Looping
7. Which of the following is not an alternative or branching statement in Python?
a) simple if b) if..else c) if..elif d) switch
8. The simplest of all decision-making statements is
a) simple if b) if..else c) if..elif d) switch
9. Which of the following statement provides control to check the true block as well as
the false block?
a) simple if b) if..else c) if..elif d) switch
10. How many blocks are provided by if..else statement?
a) 2 b) 4 c) 1 d) No Limit
11. An alternate method of using conditional operator is
a) simple if b) if..else c) if..elif d) switch
12. Which of the following clause can be used when we need to construct a chain of if
statement(s)?
a) else: b) goto : c) else if: d) elif:

..149..
12 – Computer Science

13. In if..elif..else statement if all the given conditions are false, it executes
a) elif block b) else
c) Error d) Comes out of if..elif..else
14. How many ‘elif’ clause can be used in if..elif..else statement?
a) 2 b) 4 c) 1 d) No Limit
15. elif is an abbreviation of
a) else if ladder b) else if another
c) else if d) None of these
16. In Python, which is required to indicate which block of code the segment belongs to?
a) Tabs b) Indentation
c) Spaces d) Blank spaces
17. Iteration is also called as
a) Alternative b) Sequential c) Branching d) Looping
18. A statement which allows to execute a statement or group of statements multiple
times is
a) Alternative b) Sequential c) Branching d) Loop
19. How many types of looping is provided by Python?
a) 1 b) 2 c) 3 d) 4
20. In the while loop, the condition is any valid Boolean expression returning
a) True b) False
c) True or False d) True and False
21. Which of the following is optional in while loop?
a) Condition b) else c) Initialization d) Updation
22. while loop is also called as
a) Entry check loop b) Exit check loop
c) Conditional loop d) do..while loop
23. What is the output for the following code?
i = 10
while (i<=15):
print(i,end=’\t’)
i+=2
a) 10 11 12 13 14 15 b) 11 13 15 c) 10 12 14 d) 10 12 14 15

..150..
12 – Computer Science

24. The parameter used to give any escape sequences like \n, \t and so on.. in print
statement is
a) sep b) end c) esc d) seq
25. The parameter used to specify any special characters like ; , and so on… as separator
in print statement is
a) sep b) end c) esc d) seq
26. What is the output for the following code?
i = 10
while (i<=15):
print(i,end=’\t’)
i+=1
else:
print(i)
a) 10 11 12 13 14 15 16 b) 11 13 15 16
c) 10 12 14 16 d) 10 12 14 15 16
27. Which of the following is the most comfortable loop?
a) while b) for c) do..while d) switch
28. for loop is also called
a) do..while loop b) Exit check loop
c) Conditional loop d) Entry check loop
29. In for loop, which of the following refers to the initial, final and increment value?
a) else b) counter_variable c) sequence d) counter
30. range() generates a list of values starting from start till
a) stop b) stop-1 c) step d) step-1
31. The correct syntax for range() is
a) range(start,stop[,step]) b) range(start,step,[stop])
c) range(start,[stop],step) d) range([start],stop,step)
32. Which of the following range() gives the output range start from 30 and end at 6?
a) range(3,30,6) b) range(6,30,-3)
c) range(30,3,-3) d) range(2,30,-3)
33. What is the stop value for the following statement?
range(30)
a) 0 b) 1 c) 30 d) 29
..151..
12 – Computer Science

34. What is the start value for the following statement?


range(20)
a) 0 b) 1 c) 20 d) 19
35. What is the output for the following code?
for i in range(2,10,2):
print(i,end=’ ‘)
a) 2 4 6 8 10 b) 2 4 6 8 c) 2 4 6 d) 1 2 4 6 8
36. Which of the following creates blocks and sub-blocks like how we create within set of
{} in C, C++ etc.?
a) Tabs b) Indentation
c) Spaces d) Blank spaces
37. A loop placed within another loop is called
a) Connected loop b) Embedded loop
c) Nested loop d) Circle loop
38. Which of the following is used to unconditionally transfer the control from one part
of the program to another?
a) break b) continue c) pass d) jump
39. How many keywords are there to achieve jump statement in Python?
a) 1 b) 2 c) 3 d) 4
40. Which is not a jump statement in Python?
a) break b) continue c) pass d) jump
41. What is the output for the following code?
for word in "Computer Science":
if word=="e":
break
print(word, end='')
a) Computr Scinc b) Compute
c) Comput d) Computer Scinc
42. Which of the following terminates the loop containing it?
a) break b) continue c) pass d) jump
43. The statement which is used to skip the remaining part of the loop and start with next
iteration is
a) break b) continue c) pass d) jump
..152..
12 – Computer Science

44. What is the output for the following code?


for word in "Computer Science":
if word=="e":
continue
print(word, end='')
a) Computr Scinc b) Compute
c) Comput d) Computer Scinc
45. Which of the following is a null statement in Python?
a) break b) continue c) pass d) null
46. Which of the following statement is completely ignored by Python interpreter?
a) pass b) null c) break d) continue
47. The statement used as a placeholder is
a) break b) continue c) pass d) null
48. What is the output for the following code?
i=1
while True:
if i%5==0:
break
print(i,end=' ')
i+=1
a) 1 2 b) 1 2 3 c) 1 2 3 4 5 d) 1 2 3 4
II. Additional Two and Three Marks:
1. What is Sequential Statement? Give Example.
A sequential statement is composed of a sequence of statements which are
executed one after another. A code to print your name, address and phone number
is an example of sequential statement.
Example:
print ("Hello! This is Shyam")
print ("43, Second Lane, North Car Street, TN")
2. What is alternative or branching statement.
In our day-to-day life we need to take various decisions and choose an alternate
path to achieve our goal. Based on a decision to choose one part to another part of a
program. This is called an alternative (or) branch.
..153..
12 – Computer Science

3. Write short note on simple if statement.


Simple if is the simplest of all decision-making statements. Condition should be in
the form of relational or logical expression.

Syntax:
if <condition>:
statements-block1
Example:
x=int (input("Enter your age :"))
if x>=18:
print ("You are eligible for voting")
Output:
Enter your age :34
You are eligible for voting
4. What is Looping? Write its types.
A loop executes set of statements or a block of code several of times till the
condition is satisfied.
Python provides two types of looping constructs:
• while loop
• for loop
5. What is Nested loop structure?
A loop placed within another loop is called as nested loop structure. One can place
a while within another while; for within another for; for within while and while within
for to construct such nested loops.
Example:
for i in range(65,70):
for j in range(65,i+1):
print(chr(j),end='\t')
print('\n')
6. What is the use of end and sep parameters in print() function?
➢ end parameter can be used when we need to give any escape sequences like ‘\t’
for tab, ‘\n’ for new line and so on.

..154..
12 – Computer Science

➢ sep as parameter can be used to specify any special characters like, (comma) ;
(semicolon) as separator between values.
7. Write the importance of indentation in python.
Indentation only creates blocks and sub-blocks like how we create blocks within a
set of { } in languages like C, C++ etc.
8. What is the use of Jump Statements in Python.
The jump statement in Python, is used to unconditionally transfer the control from
one part of the program to another.
There are three keywords to achieve jump statements in Python :
• break
• continue
• pass
9. Write about break statement in python.
✓ The break statement terminates the loop containing it.
✓ Control of the program flows to the statement immediately after the body of the
loop.
Syntax:
break
Example:
for word in “Government”:
if word ==’n’:
break;
print(word)
Output:
Gover
10. What is the use of continue statement in Python?
continue statement is used to skip the remaining part of a loop and start with next
iteration.
Syntax:
continue
Example:
for word in “Government”:
if word ==’n’:
continue;
print(word)

..155..
12 – Computer Science

Output:
Govermet
11. What is the use of PASS statement in Python?
✓ pass statement in Python programming is a null statement.
✓ Nothing happens when pass is executed, it results in no operation.
✓ pass statement is generally used as a placeholder.
Syntax:
pass
Example:
for word in “Government”:
if word ==’n’:
pass;
print(word)
Output:
Government
III. Additional Five Marks:
1. Explain While loop with example.
while loop is entry check loop. The condition is placed in the beginning of the body
of the loop. The statements in the loop will not be executed even once if the condition
is false at the time of entering the loop.
Syntax:
while <condition>:
statements block 1
[else:
statements block2]
The statements block1 is kept executed till the condition is True. If the else part
is written, it is executed when the condition is tested False.
Example:
i=10
while (i<=15):
print (i, end='\t')
i=i+1
Output:
10 11 12 13 14 15

..156..
7. Python Functions

I. Additional One Marks:


1. Which of the following are named blocks of code that are designed to do specific job?
a) Subroutines b) Functions c) Modules d) Library
2. A function can be called by its
a) Name b) Prototype c) Parameters d) Arguments
3. A group of related statements that perform a specific task is
a) Subroutines b) Library c) Modules d) Functions
4. Function blocks begin with
a) the keyword ‘def’ followed by function name and parenthesis
b) function name followed by ‘def’ keyword and parenthesis
c) the keyword ‘def’ followed by function name and square brackets
d) function name followed by ‘rec’ keyword and parenthesis
5. One or more lines of code, grouped together as one big sequence of statements while
execution is
a) Code b) Block c) Segment d) Module
6. In Python, statements in a block are written with
a) Tabs b) Indentation
c) Spaces d) Blank spaces
7. Function code block always comes after
a) Semicolon(;) b) Comma(,) c) Colon(:) d) Hash(#)
8. Which of the following statement indicates end of the function?
a) Function prototype b) Function name
c) end d) return
9. Python keywords should not be used as
a) Function name b) Identifiers
c) Both a and b d) None of these
10. A block within a block is called
a) Connected block b) Embedded block
c) Nested block d) Circle block
11. A function defined by the users are called
a) User-Defined functions b) Built-in functions
c) Lambda functions d) Recursive functions

..157..
12 – Computer Science

12. What is the output of the following code:


def hello():
print(“hello – Python”)
return
print(hello())
a) hello – Python b) Hello – Python c) None d) None
None None hello – Python python
13. What is the output of the following code?
def hello():
return
print(hello())
a) hello – Python b) Hello – Python c) None d) hello
14. Which of the following can be passed to functions?
a) Parameters b) Arguments c) Objects d) All of these
15. The variables used in the function definition are called
a) Parameters b) Arguments c) Identifiers d) Constants
16. The values we pass to the function parameters are called
a) Parameters b) Arguments c) Identifiers d) Constants
17. How many types of arguments are used by functions in Python?
a) 1 b) 2 c) 3 d) 4
18. The arguments passed to a function in correct positional order is
a) Keyword arguments b) Variable – length argument
c) Default argument d) Required arguments
19. In required argument, the number of arguments in the function call should match
exactly with
a) Function Definition b) Function Call
c) Both a and b d) None of these
20. Which of the following allows you to put arguments in improper order?
a) Keyword arguments b) Variable – length argument
c) Default argument d) Required argument
21. An argument that takes a default value if no value is provided in the function call is
a) Keyword arguments b) Variable – length argument
c) Default argument d) Required argument
..158..
12 – Computer Science

22. Select the correct function call for the given function.
def printstring(str):
print(str)
return
a) printstring(“Welcome”) b) printstring()
c) printstring(self) d) printstring(Welcome)
23. The following code is an example for
def sample(b,c,a):
print(“Welcome”)
return
sample(a,b,c)
a) Keyword arguments b) Variable – length argument
c) Default argument d) Required argument
24. The symbol used to define arguments in Variable – length argument is
a) # b) * c) $ d) :
25. What is the output of the following code?
def add(a,b=3,c):
return a+b+c
print(add(5,10,15))
a) 30 b) 23 c) 10 d) Error
26. What is the output of the following code?
def add(a,b=3,c=2):
return a+b+c
print(add(5,10,15))
a) 30 b) 23 c) 10 d) Error
27. Non-Keyword variable arguments are called
a) List b) Tuples c) Set d) Dictionary
28. In how many methods we can pass arguments in Variable Length arguments?
a) 1 b) 2 c) 3 d) 4
29. Which of the following function is mostly used for creating small and one-time
anonymous function?
a) User-Defined functions b) Built-in functions
c) Lambda functions d) Recursive functions
..159..
12 – Computer Science

30. A function that is defined without a name is called


a) User-Defined functions b) Built-in functions
c) Lambda functions d) Recursive functions
31. In Python, anonymous functions are defined using the keyword,
a) def b) rec c) lambda d) return
32. Anonymous functions are also called as
a) User-Defined functions b) Built-in functions
c) Lambda functions d) Recursive functions
33. What is the output of the following code?
Sum=lambda a1,a2:a1+a2
print(Sum(20,40))
print(Sum(-20,40))
a) 60 b) 20 c) 240 d) 60
-60 -20 20 20
34. Which of the following statement causes your function to exit and returns a value to
its caller?
a) def b) rec c) lambda d) return
35. Which of the following statement(s) is/are correct?
(I) Only one return statement is executed at run time.
(II) Function contains only one return statement
(III) Function can contain many return statement
a) I is correct b) II & III are correct
c) I & III are correct d) I, II & III are correct
36. Which of the following refers to the part of the program, where it is accessible, i.e.,
area where you can refer it?
a) Scope b) return
c) Lambda d) None of these
37. How many types of accessibility are there in Python?
a) 1 b) 2 c) 3 d) 4
38. When a variable is created inside the function/block, the variable becomes
a) Global b) Enclosed c) Local d) Built – in
39. Which of the following variable can be accessed anywhere in the program?
a) Global b) Enclosed c) Local d) Built – in
..160..
12 – Computer Science

40. What is the output of the following code?


def loc():
y = “Local”
loc()
print(y)
a) Local b) y c) y = “Local” d) Error
41. What is the output of the following code?
c=1
def add():
c=c+2
print(c)
add()
a) 1 b) 3 c) 2 d) Error
42. What is the output of the following code?
x=0
def add():
global x
x=x+5
print(x)
add()
print(x)
a) 5 b) 10
10 10
c) 5 d) Error
5
43. Which of the following keyword is necessary to modify the value of global variable
inside the function?
a) glob b) global
c) glob scope d) public
44. What is the output of the following code?
x = -15
print(abs(x))
a) 15 b) -15 c) +15 d) abs(x)
..161..
12 – Computer Science

45. What is the output of the following code?


x=5
def loc():
x = 10
print(x)
loc()
print(x)
a) 5 b) 10 c) 5 d) 10
10 10 5 5
46. The function which returns a binary string prefixed with “0b” for the given integer
number is
a) ord() b) chr() c) bin() d) type()
47. The function which returns the minimum value in a list is
a) small() b) short() c) less() d) min()
48. The function which returns the nearest integer of its input is
a) format() b) abs() c) id() d) round()
49. What is the output of the following code?
x = -18.3
print(round(x))
a) 18 b) -18 c) -18.5 d) -19
50. What is the output of the following code?
x = 17.89
print(round(x,1))
a) 17.8 b) 18.0 c) 17.89 d) 17.9
51. The function which returns the largest integer less than or equal to the given value is
a) floor() b) round() c) ceil() d) pow()
52. Which of the following module is necessary to use all mathematical functions?
a) cmath b) maths c) math d) mat
53. Which of the following function does not require mathematical function?
a) pow() b) floor() c) sqrt() d) ceil()
54. The value returned by a function may be used as an argument for another function in
a nested manner is called
a) lambda b) decomposition c) composition d) anonymous
..162..
12 – Computer Science

55. When a function calls itself is known as


a) lambda b) recursion c) composition d) anonymous
56. A process would iterate indefinitely if not stopped by some condition! Such a process
is known as
a) finite iteration b) infinite iteration
c) recursive iteration d) composite iteration
57. Default recursive calls in Python is
a) 1000 b) 2000 c) 1100 d) 2200
58. Default recursive call limits can be changed by using
a) sys.setupperlimit() b) sys.sethigherlimit()
c) sys.setrecursivelimit() d) sys.setrecursionlimit()
59. Which of the following is optional in Python function?
a) rec b) return c) def d) Both a and b
60. What is the output of the following statement?
eval(‘25*2-5*4’)
a) -300 b) 180 c) 30 c) -450
II. Additional Two and Three Marks:
1. Write short note on different types of functions.
❖ User-defined functions: Functions defined by the users themselves.
❖ Built-in functions: Functions that are inbuilt with in Python.
❖ Lambda functions: Functions that are anonymous un-named function.
❖ Recursion functions: Functions that calls itself is known as recursive.
2. What is a block?
A block is one or more lines of code, grouped together so that they are treated as
one big sequence of statements while execution. In Python, statements in a block are
written with indentation.
3. What is nested block?
A block within a block is called nested block. When the first block statement is
indented by a single tab space, the second block of statement is indented by double
tab spaces.
4. What are the advantages of user defined functions?
❖ Functions help us to divide a program into modules. This makes the code easier to
manage.
..163..
12 – Computer Science

❖ It implements code reuse. Every time you need to execute a sequence of


statements, all you need to do is to call the function.
❖ Functions, allows us to change functionality easily, and different programmers can
work on different functions.
5. What is the difference between parameters and arguments?
Parameters are the variables used in the function definition whereas arguments
are the values we pass to the function parameters.
6. What are types of arguments?
Arguments are primarily 4 types of functions that one can use:
1. Required arguments 2. Keyword arguments
3. Default arguments and 4. Variable-length arguments.
7. What is anonymous or lambda function?
❖ In Python, anonymous function is a function that is defined without a name. While
normal functions are defined using the def keyword.
❖ In Python anonymous functions are defined using the lambda keyword. Hence,
anonymous functions are also called as lambda functions.
8. What is the use of lambda or anonymous function?
❖ Lambda function is mostly used for creating small and one-time anonymous
function.
❖ Lambda functions are mainly used in combination with the functions like filter(),
map() and reduce().
III. Additional Five Marks:
1. Explain in detail about different types of function arguments in python.
The different function arguments are
1. Required arguments 2. Keyword arguments
3. Default arguments 4. Variable-length arguments
Required Arguments:
➢ Required Arguments are the arguments passed to a function in correct positional
order.
➢ Here, the number of arguments in the function call should match exactly with the
function definition. You need at least one parameter to prevent syntax errors to
get the required output.

..164..
12 – Computer Science

Example:
def printstring(str):
print ("Example - Required arguments ")
print (str)
return
✓ printstring(“Welcome”)
When the above code is executed, it produces the following error.
✓ if we use printstring (“Welcome”) then the output is
Example - Required arguments
Welcome
Keyword Arguments:
➢ Keyword arguments will invoke the function after the parameters are recognized
by their parameter names.
➢ The value of the keyword argument is matched with the parameter name and so,
one can also put arguments in improper order (not in order).
Example:
def printdata (name, age):
print ("Example-3 Keyword arguments")
print ("Name :",name)
print ("Age :",age)
return
✓ If you call the function printdata(name="Vijay",age=25), you will get the
following output
Name : Vijay
Age :25
✓ If you call the function printdata (age=25,name="Vijay") by changing the order
of parameters, you will get the following output
Name :Vijay
Age :25
Default Arguments:
➢ In Python the default argument is an argument that takes a default value if no
value is provided in the function call.

..165..
12 – Computer Science

Example:
def printinfo( name, salary = 3500):
print (“Name: “, name)
print (“Salary: “, salary)
return
printinfo(“Vijay Akash”)
✓ When the above code is executed, it produces the following output
Name :Vijay Akash
Salary :3500
Variable-Length Arguments:
➢ In some instances you might need to pass more arguments than have already been
specified. Variable-Length arguments can be used instead.
➢ An asterisk (*) is used to define such arguments.
Example:
def printnos (*nos):
for n in nos:
print(n)
return
✓ printnos(1,2) If you call the function with two parameters, you get the output
as 1 2.
✓ printnos(10,20,30) If you call the function with three parameters, you will get
the output as 10 20 30.
2. Explain the return statement in detail.
❖ The return statement causes your function to exit and returns a value to its caller.
The point of functions in general is to take inputs and return something.
❖ The return statement is used when a function is ready to return a value to its caller.
So, only one return statement is executed at run time even though the function
contains multiple return statements.
❖ Any number of 'return' statements are allowed in a function definition but only
one of them is executed at run time.
Syntax:
return [expression list]

..166..
12 – Computer Science

➢ This statement can contain expression which gets evaluated and the value is
returned.
➢ If there is no expression in the statement or the return statement itself is not
present inside a function, then the function will return the None object.
Example:
def usr_abs (n):
if n>=0:
return n
else:
return –n
x=int (input(“Enter a number :”)
print (usr_abs (x))
Output 1: Output 2:
Enter a number : 25 Enter a number : -25
25 25
3. What is the use of format() function in Python?
It returns the output based on the given format
i. Binary format. Outputs the number in base 2.
ii. Octal format. Outputs the number in base 8.
iii. Fixed-point notation. Displays the number as a fixed-point number. The default
precision is 6.
Syntax:
format (value [, format_ spec])
Example:
x= 14
y= 25
print ('x value in binary :',format(x,'b'))
print ('y value in octal :',format(y,'o'))
print('y value in Fixed-point no ',format(y,'f '))
Output:
x value in binary : 1110
y value in octal : 31
y value in Fixed-point no : 25.000000
..167..
8. Strings and String Manipulations

I. Additional One Marks:


1. Which of the following is used to handle array of characters?
a) Word b) Character c) String d) Letters
2. Strings in Python can be enclosed within
a) Single quotes b) Double quotes
c) Triple quotes d) Any of these
3. String is a sequence of
a) Bicode character b) Unicode character
c) Tricode character d) None of these
4. String in single quotes cannot hold any other single quoted character in it. To
overcome this problem, you have to use
a) Nested single quotes b) Double quotes
c) Triple quotes d) Single quotes
5. Strings which contain double quotes should be define within
a) Nested single quotes b) Double quotes
c) Triple quotes d) Single quotes
6. Defining strings within triple quotes also allows creation of
a) Multiline String b) Multiple String
c) Paragraph String d) Double line String
7. Index values are otherwise called as
a) Size b) Length c) Superscript d) Subscript
8. Which of the following is used to access and manipulate the strings in Python?
a) Size b) Index value c) Subscript d) Either b or c
9. The positive subscript of a string always starts from
a) 0 b) 1 c) 2 d) 3
10. The negative index of a string will be assigned from the
a) last character to the first character b) first character to the last character
c) both ends d) No negative index
11. What is the output for the following code?
str = “School”
print(str[2])
a) c b) o c) h d) l

..168..
12 – Computer Science

12. What is the output for the following code?


str = “School”
print(str[-2])
a) c b) o c) h d) l
13. Which of the following statement(s) is/are correct?
I. Strings in Python are immutable.
II. String modifications and deletion is not allowed in Python.
III. To modify the string, a new string value can be assigned to the existing string
variable.
a) I Only b) I and II c) II and III d) I, II and III
14. What is the output for the following code?
str=”Cat”
str[0]=”B”
print(str)
a) Bat b) Cat c) CaB d) Error
15. The function which allows you to change all occurrences of a particular character in a
string is
a) modify() b) change() c) replace() d) update()
16. The command used to remove entire string variable is
a) del b) delete c) rem d) remove
17. Del command in Python is used to
a) Remove content of a string variable b) Delete the string variable
c) Delete the memory d) None of these
18. Adding more strings at the end of an existing string is known as
a) Concatenation b) Append c) Repeating d) String Slice
19. The operator used to display a string in multiple number of times is
a) + b) & c) * d) ++
20. Which of the following is a substring of a main string?
a) Concatenation b) Append c) Repeating d) String Slice
21. A substring can be taken from the original string by using
a) [ ] b) ( ) c) { } d) < >
22. Which of the following is also known as a slicing operator?
a) { } b) ( ) c) [ ] d) < >
..169..
12 – Computer Science

23. What is the output for the following code?


str=”Computer”
print(str[0:5])
a) Compute b) Compu c) Computer d) Comput
24. Stride is a ________ argument in slicing operation.
a) first b) second c) third d) fourth
25. What is the output for the following code?
str=”Computer”
print(str[::2])
a) Comue b) Cmue c) mue d) Coptr
26. The default value of stride when slicing string is
a) -1 b) 0 c) 1 d) 2
27. The formatting character used to display String is
a) %c b) %s c) %f d) %i
28. The formatting character used to display unsigned decimal integer is
a) %i b) %e c) %g d) %u
29. Escape sequences starts with a
a) Slash b) Forward slash c) Backslash d) Modulo
30. The escape sequence for ASCII Linefeed is
a) \n b) /n c) \l d) /l
31. The escape sequence for ASCII Carriage return is
a) \a b) \b c) \c d) \r
32. The escape sequence for ASCII Vertical Tab is
a) \a b) \t c) \v d) \r
33. The function used with string is very versatile and powerful function used for
formatting strings is
a) capitalize() b) format() c) title() d) ord()
34. Which of the following is used as placeholders or replacement fields which get
replaced along with format() function?
a) [ ] b) ( ) c) < > d) { }
35. Which of the following function returns the length of the string?
a) len(str) b) str.len()
c) length(str) d) str.length()
..170..
12 – Computer Science

36. What is the output for the following code?


str1=”Welcome”
print(str1.center(15,’*’))
a) ***Welcome***** b) *******Welcome*******
c) ****Welcome**** d) ****welcome****
37. The function used to return True if the string contains only letters and digits is
a) isalpha() b) isdigit() c) isalphanum() d) isalnum()
38. The function used to change case of every character to its opposite and case vive-versa is
a) changecase() b) swapcase() c) titlecase() d) uppercase()
39. The function which returns the number of substrings occurs within the given range is
a) count() b) find() c) search() d) None of these
40. Which of the operator is used with strings to determine whether the string is present
in another string?
a) in and not in b) and, or
c) between d) not between
II. Additional Two and Three Marks:
1. How will you access characters in a string?
➢ Once you define a string, python allocate an index value for its each character.
These index values are otherwise called as subscript which are used to access and
manipulate the strings. The subscript can be positive or negative integer numbers.
➢ The positive subscript 0 is assigned to the first character and n-1 to the last
character, where n is the number of characters in the string.
➢ The negative index assigned from the last character to the first character in
reverse order begins with -1.
Example:
String S C H O O L
Positive subscript 0 1 2 3 4 5
Negative subscript -6 -5 -4 -3 -2 -1
2. Write short note on replace() function.
Python does not support any modification in its strings. But, it provides a function
replace() to change all occurrences of a particular character in a string.
Syntax:
replace(“char1”, “char2”)
..171..
12 – Computer Science

✓ The replace function replaces all occurrences of char1 with char2.


Example:
>>> str1="How are you"
>>> print (str1)
How are you
>>> print (str1.replace("o", "e"))
Hew are yeu
3. What is the use of string formatting operators?
The string formatting operator % is used to construct strings, replacing parts of
the strings with the data stored in variables.
Syntax:
(“String to be display with %val1 and %val2” %(val1, val2))
Example:
name = "Rajarajan"
mark = 98
print ("Name: %s and Marks: %d" %(name,mark))
Output:
Name: Rajarajan and Marks: 98
4. List some of the formatting characters in Python.
Formatting
Usage
characters
%c Character
%d (or) %i Signed decimal integer
%s String
%u Unsigned decimal integer
%o Octal integer
Hexadecimal integer (lower case x refers a-f; upper case X
%x or %X
refers A-F)
%e or %E Exponential notation
%f Floating point numbers
%g or %G Short numbers in floating point or exponential notation.

..172..
12 – Computer Science

5. Write short note on escape sequences in Python.


➢ Escape sequences starts with a backslash and it can be interpreted differently.
➢ When you have use single quote to represent a string, all the single quotes inside
the string must be escaped.
➢ Similar is the case with double quotes.
Escape Sequence Description
\newline Backslash and newline ignored
\\ Backslash
\' Single quote
\" Double quotes
\a ASCII Bell
\b ASCII Backspace
\n ASCII Linefeed
\r ASCII Carriage Return
\t ASCII Horizontal Tab
\ooo Character with octal value ooo
\xHH Character with hexadecimal value HH
6. What is the use of membership operators?
The ‘in’ and ‘not in’ operators can be used with strings to determine whether a
string is present in another string. Therefore, these operators are called as
Membership Operators.
Example:
str1=input ("Enter a string: ")
str2="chennai"
if str2 in str1:
print ("Found")
else:
print ("Not Found")
Output : 1
Enter a string: Chennai G HSS, Saidapet
Found
Output : 2
Enter a string: Govt G HSS, Ashok Nagar
Not Found
..173..
9. List, Tuples, Sets and Dictionary

I. Additional One Marks:


1. Which of the following is known as “sequence data type”?
a) List b) Tuples c) Set d) Dictionary
2. Which of the following is an ordered collection of values enclosed within square
brackets?
a) Tuples b) Set c) List d) Dictionary
3. Each value of a list is called
a) Data b) Element c) Value d) Separator
4. A list can be of
a) Numbers b) Characters c) Strings d) Any of these
5. The position of the list in the element is indexed with the numbers beginning with
a) 1 b) 0 c) -1 d) Any of these
6. In Python, the elements of list should be specified within
a) ( ) b) { } c) [ ] d) < >
7. Which of the following is the correct way of creating list?
I. Marks = [10,20,30,40]
II. Fruits = [“Apple”,”Orange”,”Mango”,”Banana”]
III. Mylist = []
IV. Data = [“Welcome”, 3.14,10,[5,10]]
a) I, II Only b) I, II, III Only
c) All are wrong d) All are correct
8. Which of the following is used to access an element in a list?
a) Start Value b) Beginning Value
c) Index Value d) Initial Value
9. In lists, index value is an integer number which can be
a) Positive b) Negative c) 0 d) Either a or b
10. What is the output for the following code?
Marks = [10,23,41,75]
print(Marks[-3])
a) 10 b) 23 c) 41 d) 75
11. A list element or range of elements can be changed or altered by using
a) := b) = c) == d) =:

..174..
12 – Computer Science

12. What is the output for the following code?


List = [10,20,30,[40,50,60],70]
print(len(List))
a) 7 b) 6 c) 5 d) 3
13. If you want to update the range of elements from 1 to 4, it should be specified as
a) [1:4] b) [0:4] c) [1:5] d) [0:5]
14. Which of the following function is used to add a single element in the list?
a) append() b) extend() c) insert() d) update()
15. The function used to add more than one element to an existing list?
a) append() b) insert() c) update() d) extend()
16. The function used to insert an element at any position of a list is
a) insert() b) append() c) extend() d) update()
17. The correct statement to insert the element ‘Ramakrishnan’ as the fourth element of
the following list is
mylist=[34,98,47,’Kannan’,’Gowrisankar’,’Lenin’,’Sreenivasan’]
a) mylist.extend(3,‘Ramakrishnan’) b) mylist.append(4,‘Ramakrishnan’)
c) mylist.insert(4, ‘Ramakrishnan’) d) mylist.insert(3, ‘Ramakrishnan’)
18. While inserting a new element in between the existing elements, at a particular
location, the existing elements shifts one position to
a) Left b) Right c) Top d) Bottom
19. How many ways are there to delete an element from a list?
a) 4 b) 3 c) 2 d) 1
20. The statement used to delete entire list is
a) clear b) del c) erase d) remove
21. The statement used to delete all the elements in list, but retains the list is
a) clear b) del c) erase d) remove
22. The function used to create a list with sequence of values is
a) value() b) series() c) range() d) ranges()
23. What is the output for the following code?
li = list(range(2,11,2))
print(li)
a) [1,3,5,7,9] b) [2,4,6,8,10]
c) [2,4,6,8] d) [1,2,3,4,5,6,7,8,9,10]
..175..
12 – Computer Science

24. The statement >>>del mysubject[1:3] deletes


a) First to Third elements b) First and Second elements
c) Second and Third elements d) Second to Fourth elements
25. The correct syntax for list comprehension is
a) list=[expression for variable in range] b) expression = [for variable in range]
c) list=[data for variable in range] d) data = [for variable in range]
26. What is the output for the following code?
S=[x**2 for x in range(1,11)]
print(S)
a) [1,2,3,4,5,6,7,8,9,10] b) [1,2,3,4,5,6,7,8,9,10,11]
c) [1,4,9,16,25,36,49,64,81,100] d) [2,4,6,8,10]
27. What is the output for the following code?
mylist=[36,12,12]
x=mylist.index(12)
print(x)
a) 0 b) 1 c) -1 d) 2
28. The function used to display the list in descending order is
a) list.sort() b) list.sort(reverse)
c) list.reverse(True) d) list.sort(reverse=True)
29. Tuples consists of a number of values separated by comma and enclosed within
a) [ ] b) { } c) < > d) ( )
30. Which of the following statement(s) is/are wrong?
I. Tuples consists of a number of values separated by comma
II. The elements of a tuple are changeable
III. Iterating tuples is faster than list
IV. The elements of a tuple can be even defined with parenthesis
a) I and III b) I and II c) III and IV d) II and IV
31. The correct way of creating tuple is
a) tuple_name = (E1,E2,….En) b) tuple_name=( )
c) tuple_name=tuple([list elemts]) d) All of these
32. Which of the following function is used to know the data type of a python object?
a) data() b) type()
c) format() d) datatype()
..176..
12 – Computer Science

33. The function used to return the index value of the first recurring element is
a) id() b) value() c) index() d) id_value()
34. The function used to create a tuple is
a) tup() b) mytup() c) mytuple() d) tuple()
35. Which of the following special character to be added at the end of the element while
creating a tuple?
a) . (Period) b) ,(Comma) c) – (Hyphen) d) ; (Semicolon)
36. The correct way of declaring a tuple with one element is
a) tup=(10,) b) tup=(10.) c) tup=(10-) d) tup=(10);
37. Creating a tuple with one element is called
a) Single Tuple b) One Tuple
c) Singleton Tuple d) Unique Tuple
38. Which of the following is a mutable and an unordered collection of elements without
duplicates?
a) List b) Tuple c) Set d) Dictionary
39. A set is created by placing all the elements separated by comma within
a) [ ] b) { } c) ( ) d) < >
40. What is the output for the following code?
>>> S1={1,2,2,’A’,3.14}
>>> print(S1)
a) {1,2,’A’,3.14} b) {1,2,2,’A’,3.14}
c) Error d) No Output
41. When you print the elements from a set, Python shows the values in
a) Same order b) Ascending order
c) Different order d) Descending order
42. A List or Tuple can be converted as set by using
a) set() b) set_convert() c) convert() d) set-convert()
43. How many set operations are supported by Python?
a) 1 b) 2 c) 3 d) 4
44. The symbol used to perform union of two sets is
a) & b) | c) - d) ^
45. The symbol used to perform difference of two sets is
a) & b) | c) - d) ^
..177..
12 – Computer Science

46. The symbol used to perform intersection of two sets id


a) & b) | c) - d) ^
47. The symbol used to perform symmetric_difference set operation in python is
a) & b) | c) - d) ^
48. The keys in a Python dictionary is separated by
a) . (Period) b) ,(Comma) c) :(Colon) d) ; (Semicolon)
49. What is the output for the following code?
>>> Dict = {x : 2 * x for x in range(1,4)}
a) {1:2,2:4,3:9,4:16,5:25} b) {1:2,2:4,3:6}
c) {1:2,2:4,4:16} d) {1:2,2:4,3:9,4:16}
50. The function used to delete all elements in a dictionary is
a) del() b) clear() c) delete() d) clean()
II. Additional Two and Three Marks:
1. How will you create a list in python?
In python, a list is simply created by using square bracket. Th e elements of list
should be specified within square brackets.
Syntax:
Variable = [element-1, element-2, element-3 …… element-n]
Example:
Marks = [10, 23, 41, 75]
Fruits = [“Apple”, “Orange”, “Mango”, “Banana”]
2. How will you find length of a List?
➢ The len( ) function in Python is used to find the length of a list. (i.e., the number
of elements in a list).
Example:
>>> MySubject = [“Tamil”, “English”, “Comp. Science”, “Maths”]
>>> len(MySubject)
4
3. Write short note on List comprehension.
List comprehension is a simplest way of creating sequence of elements that satisfy
a certain condition.
Syntax:
List = [ expression for variable in range ]
..178..
12 – Computer Science

Example:
>>> squares = [ x ** 2 for x in range(1,11) ]
>>> print (squares)
Output:
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
4. What is Singleton tuple?
➢ While creating a tuple with a single element, add a comma at the end of the
element.
➢ In the absence of a comma, Python will consider the element as an ordinary data
type; not a tuple.
➢ Creating a Tuple with one element is called “Singleton” tuple.
Example:
(i) >>> MyTup4 = (10) (ii) >>> MyTup5 = (10,)
>>> type(MyTup4) >>> type(MyTup5)
<class 'int'> <class 'tuple'>
5. What is Dictionary?
➢ In python, a dictionary is a mixed collection of elements. Unlike other collection
data types such as a list or tuple, the dictionary type stores a key along with its
element.
➢ The keys in a Python dictionary is separated by a colon ( : ) while the commas work
as a separator for the elements.
➢ The key value pairs are enclosed with curly braces { }.
6. Write note on Dictionary Comprehensions.
In Python, comprehension is another way of creating dictionary. The following is
the syntax of creating such dictionary.
Syntax:
Dict = { expression for variable in sequence [if condition] }
The if condition is optional and if specified, only those values in the sequence are
evaluated using the expression which satisfy the condition.
Example:
Dict = { x : 2 * x for x in range(1,10)}
Output:
{1: 2, 2: 4, 3: 6, 4: 8, 5: 10, 6: 12, 7: 14, 8: 16, 9: 18}

..179..
10. Python Classes and Objects

I. Additional One Marks:


1. Which of the following is an object-oriented programming language?
a) C b) QBASIC c) Python d) COBOL
2. Theoretical concepts of classes and objects are very similar to that of
a) C b) C++ c) JAVA d) Oracle
3. Collection of data and function that act on those data is called
a) Class b) Inheritance c) Overloading d) Object
4. Which of the following is a template for the object?
a) Class b) Inheritance
c) Overloading d) Polymorphism
5. Objects are also called as
a) Class Variable b) Instance of a class
c) Member variable d) Both a and b
6. In Python, every class has a unique name followed by
a) Semicolon(;) b) Period(.) c) Colon(:) d) None
7. Functions defined within a class are called
a) Attributes b) Objects c) Methods d) Members
8. The class members should be accessed through
a) Objects b) Instance of a class c) Class variable d) All of these
9. The process of creating object is called as
a) Class Initialization b) Class Instantiation
c) Class Declaration d) Class Definition
10. Any class member can be accessed by using object with
a) Dot operator b) Comma operator
c) Colon operator d) Addition operator
11. In Python, if a method takes no arguments, it should be defined with the first
argument called
a) short b) self c) name d) main
12. A special function that is automatically executed when an object of a class is created
a) Constructor b) Destructor c) Methods d) Function
13. Which of the following function acts as a constructor?
a) int b) constructor c) const d) init

..180..
12 – Computer Science

14. Constructor function must begin and end with


a) ( ) b) { } c) __ d) [ ]
15. A special method gets executed automatically when an object exit from the scope is
a) Constructor b) Destructor c) Methods d) Function
16. Which of the following is a destructor function?
a) _destruct_ b) _clear_ c) __del__ d) _exit_
17. In Python, by default the variables which are defined inside the class is
a) Private b) Public c) Protected d) Hidden
18. A variable prefixed with double underscore becomes
a) Private b) Public c) Protected d) Hidden
19. Which of the following variables can be accessed only within the class?
a) Private b) Public c) Protected d) Hidden
20. A variable accessed anywhere in the program is
a) Private b) Public c) Protected d) Hidden
21. The key features of Object-Oriented Programming is
a) Function b) Arrays
c) Classes and Objects d) Structures
22. Which of the following is the private class variable?
a) &&num b) ||num
c) ##num d) __num
23. The main building block in Python is
a) Objects b) Class
c) Constructor d) Destructor
24. Any class member can be accessed by using object with a
a) Semicolon(;) Operator b) Hash(#) Operator
c) Colon(:) Operator d) Dot(.) Operator
II. Additional Two and Three Marks:
1. How will you create objects for a class?
Once a class is created, next you should create an object or instance of that class.
The process of creating object is called as “Class Instantiation”.
Syntax:
Object_name = class_name( )
✓ The class instantiation uses function notation ie. class_name with paranthesis ().

..181..
12 – Computer Science

Example:
class Sample:
x, y = 10, 20
S=Sample( )
✓ In class instantiation process, we have created an object S to access the
members of the class.
2. How will you access class members?
Any class member ie. class variable or method (function) can be accessed by using
object with a dot ( . ) operator.
Syntax:
Object_name . class_member
Example:
class Sample:
x, y = 10, 20
S=Sample( )
print("Value of x = ", S.x)
print("Value of y = ", S.y)
Output:
Value of x = 10
Value of y = 20
3. What is the use of private and public data members?
➢ The variables which are defined inside the class is public by default. These
variables can be accessed anywhere in the program using dot operator.
➢ A variable prefixed with double underscore becomes private in nature. These
variables can be accessed only within the class.
III. Additional Five Marks:
1. Explain the class methods with an example.
➢ Python class function or Method is very similar to ordinary function with a small
difference that, the class method must have the first argument named as self.
➢ No need to pass a value for this argument when we call the method. Python
provides its value automatically. Even if a method takes no arguments, it should
be defined with the first argument called self.

..182..
12 – Computer Science

➢ If a method is defined to accept only one argument it will take it as two arguments
ie. self and the defined argument.
➢ When you declare class variable within class, methods must be prefixed by the
class name and dot operator.
Example:
class Odd_Even:
even = 0
def check(self, num):
if num%2==0:
print(num," is Even number")
else:
print(num," is Odd number")

n=Odd_Even()
x = int(input("Enter a value: "))
n.check(x)
✓ When you execute this program, Python accepts the value entered by the user
and passes it to the method check through object.
Output 1:
Enter a value: 4
4 is Even number
Output 2:
Enter a value: 5
5 is Odd number
2. Explain constructor and destructor with example.
Constructor:
❖ Constructor is the special function that is automatically executed when an object of a
class is created.
❖ In Python, there is a special function called “init” which act as a Constructor.
❖ It must begin and end with double underscore.
Syntax:
def __init__(self, [args ……..]):
<statements>
..183..
12 – Computer Science

Destructor:
❖ Destructor is also a special method gets executed automatically when an object exit
from the scope.
❖ It is just opposite to constructor.
❖ In Python, __del__( ) method is used as destructor.
Syntax:
def __del__(self, [args ……..]):
<statements>
Example:
class Sample:
def __init__(self):
print("Constructor Executed")
def __del__(self):
print("Destructor Executed")
S=Sample()
Output:
Constructor Executed
Destructor Executed

..184..
11. Database Concepts

I. Additional One Marks:


1. An organized collection of data, generally stored and accessed electronically from a
computer system is
a) Data b) Database c) Information d) Table
2. Which of the following term is also used to refer to any of the DBMS, the database
system or an application associated with it?
a) Data b) Database c) Information d) Table
3. Which of the following is an example for a database?
a) Playing in the ground b) Riding in the bike
c) School class register d) Drinking water
4. Which of the following are raw facts store in a computer?
a) Tables b) Database c) Information d) Data
5. Which of the following may contain any character, text, word or a number?
a) Tables b) Database c) Data d) Information
6. A formatted data, which allows to be utilized in a significant way is
a) Tables b) Database c) Data d) Information
7. Which of the following gives a meaningful information about the data?
a) Information b) Database c) DBMS d) Tables
8. A repository collection of related data organized in a way that data can easily accesses,
managed and updated is
a) Information b) Database c) DBMS d) Tables
9. A software that allows us to create, define and manipulate database, allows users to
store, process and analyse data easily is
a) Information b) Database c) DBMS d) Tables
10. How many major components are there in DBMS?
a) 3 b) 5 c) 7 d) 4
11. In DBMS, Which is capable of understanding the Database Access Languages and
interprets into database commands for execution?
a) Hardware b) Database Access Languages
c) Data d) Software
12. The entire collection of related data in one table is referred as
a) Relation b) Table c) File d) All of these

..185..
12 – Computer Science

13. The data is organized as row and column in


a) Table b) Tuple c) Attribute d) Entity
14. A set of data for each database entry is
a) Attribute b) Record c) Relation d) Database
15. Each table column represents
a) Row b) Data c) Tuple d) Field
16. A table is also known as
a) Attribute b) Tuple c) Relation d) Data
17. A row is also known as
a) Attribute b) Tuple c) Relation d) Data
18. A column is known as
a) Attribute b) Tuple c) Relation d) Data
19. Which of the following describes how the data can be represented and accessed from
a software after complete implementation?
a) Database b) Datatype c) Data Collection d) Data Model
20. Hierarchical model was developed by
a) Windows b) IBM c) Wipro d) Apple
21. In which of the following model, data is represented as a simple tree like structure?
a) Hierarchical Model b) Object Model
c) Network Database Model d) Relational Model
22. The relational database model was first proposed by E.F.Codd in
a) 1960 b) 1970 c) 1980 d) 1990
23. Network database model is an extended form of
a) Hierarchical Model b) Object Model
c) Entity Relationship Model d) Relational Model
24. Which of the following model is easier and faster to access the data?
a) Hierarchical Model b) Object Model
c) Network Database Model d) Relational Model
25. Entity Relationship model was developed by
a) E.F. Codd b) Chen c) Edgar d) Chris Date
26. In which model, one child can have only one parent but one parent can have many children?
a) Hierarchical Model b) Object Model
c) Network Database Model d) Relational Model
..186..
12 – Computer Science

27. In ER Model, the Entities are represented by


a) Diamond b) Rectangle
c) Square d) Ellipse
28. Which of the following stores the data in the form of objects, attributes and methods?
a) Hierarchical Model b) Object Model
c) Network Database Model d) Relational Model
29. In which model, a child may have many parent nodes?
a) Hierarchical Model b) Object Model
c) Network Database Model d) Relational Model
30. Which of the following is the most widespread data model used for database
application around the world?
a) Hierarchical Model b) Object Model
c) Network Database Model d) Relational Model
31. Which of the following model is mainly used in IBM main frame computers?
a) Hierarchical Model b) Object Model
c) Network Database Model d) Relational Model
32. A model represents a one-to-many relationship is
a) Hierarchical Model b) Object Model
c) Network Database Model d) Relational Model
33. The basic structure of data in relational model is
a) Tuple b) Attributes c) Tables d) Row
34. Which of the following represents the relationship in ER diagram?
a) Diamond b) Rectangle c) Square d) Ellipse
35. Which of the data model is useful in developing a conceptual design for the database?
a) Relational Model b) ER Model c) Object Model d) HR Model
36. Which of the following model represents real world objects, attributes and
behaviours?
a) ER Model b) Relational Model
c) Object Model d) Network Model
37. In which model, relationships are created by dividing the object into entity and its
characteristics into attributes?
a) ER Model b) Relational Model
c) Object Model d) Network Model
..187..
12 – Computer Science

38. The one who manages the complete database management system is
a) End User b) Software Developers
c) Database Designers d) DBA
39. The user group is involved in developing and designing the parts of DBMS is
a) Application Programmers b) End users
c) Database Administrators d) Database Designers
40. Who is responsible for identifying the data to be stored in the database for choosing
appropriate structures to represent and store the data?
a) End User b) Software Developers
c) Database Designers d) DBA
41. RDBMS Stands for
a) Rotational Database Management System
b) Real Database Management System
c) Relational Database Management System
d) Round Database Management System
42. Which of the following is not an example for RDBMS?
a) Oracle b) Dbase c) SQLite d) MariaDB
43. Which of the following is an example for DBMS?
a) Foxpro b) Mysql c) SQL Server d) Oracle
44. The one who store, retrieve, update and delete data in database is
a) Application Programmers b) End users
c) Database Administrators d) Database Designers
45. Compared to DBMS, Data access in RDBMS is
a) Equal b) Not Equal
c) Slower d) Faster
46. Which of the following is an integral part of RDBMS in order to reduce data
redundancy and data integrity?
a) Database Consistency b) Database efficiency
c) Data Access d) Database Normalization
47. Database Normalization was first proposed by
a) Guido Van Rossum b) Chen
c) E.F. Codd d) Chris Date

..188..
12 – Computer Science

48. In which of the following relationship one row in a table is linked with only one row in
another table?
a) One-to-One b) One-to-Many
c) Many-to-One d) Many-to-Many
49. One entity is related to many other entities in
a) One-to-One b) One-to-Many
c) Many-to-One d) Many-to-Many
50. One Department has many staff members is an example for
a) One-to-One b) One-to-Many
c) Many-to-One d) Many-to-Many
51. A student can have only one exam number is an example for
a) One-to-One b) One-to-Many
c) Many-to-One d) Many-to-Many
52. Many entities can be related with only one in the other entity is
a) One-to-One b) One-to-Many
c) Many-to-One d) Many-to-Many
53. A number of staff members working in one department is an example for
a) One-to-One b) One-to-Many
c) Many-to-One d) Many-to-Many
54. A relationship occurs when multiple records in a table are associated with multiple
records in another table is
a) One-to-One b) One-to-Many
c) Many-to-One d) Many-to-Many
55. Many books in a Library are issued to many students is an example for
a) One-to-One b) One-to-Many
c) Many-to-One d) Many-to-Many
56. Customers can purchase various products and products can be purchased by many
customers is an example for
a) One-to-One b) One-to-Many
c) Many-to-One d) Many-to-Many
57. Who is the father of Relational Database?
a) Guido Van Rossum b) Chen
c) E.F. Codd d) Chris Date
..189..
12 – Computer Science

58. A procedural Query language used to query the database tables using SQL is
a) MS Access b) Relational Algebra
c) Dbase d) SQLite
59. The operator used to eliminate all attributes of the input relation but those
mentioned in the projection list is
a) Select b) Union c) Project d) Intersection
60. The operator used for selecting a subset with tuples according to a given condition is
a) Project b) Difference c) Select d) Intersection
61. In which of the following, duplicate rows are removed in the result?
a) Project b) Difference c) Select d) Intersection
62. A way of combining two relations is
a) Difference b) Union
c) Intersection d) Cartesian Product
63. A relation which includes all tuples that are in A but not in B is
a) Difference b) Set Difference c) Cartesian Product d) Union
64. The symbol used for Cartesian product is
a) π b) α c) X d) *
65. The symbol used for Select is
a) π b) ∞ c) X d) ᓂ
II. Additional Two and Three Marks:
1. What is Data?
Data are raw facts stored in a computer. A data may contain any character, text,
word or a number.
Example:
600006, DPI Campus, SCERT, Chennai.
2. What is an Information?
Information is processed data, organized and formatted; it gives a meaningful
information.
Example :
Vijay Akash is studying 9th standard.
3. What is database?
Database is a repository collection of related data organized in a way that data can
be easily accessed, managed and updated.
..190..
12 – Computer Science

4. What is DBMS?
➢ A DBMS is a software that allows us to create, define and manipulate database,
allowing users to store, process and analyse data easily.
➢ DBMS provides us with an interface or a tool, to perform various operations to
create a database, storing of data and for updating data, etc.
➢ DBMS also provides protection and security to the databases.
➢ It also maintains data consistency in case of multiple users.
5. What are the advantages of DBMS?
➢ Segregation of application program
➢ Minimal data duplication or Data Redundancy
➢ Easy retrieval of data using the Query Language
➢ Reduced development time and maintenance
6. What is Data Model?
➢ A data model describes how the data can be represented and accessed from a
software after complete implementation.
➢ It is a simple abstraction of complex real world data gathering environment.
➢ The main purpose of data model is to give an idea as how the final system or
software will look like after development is completed.
7. List the different types of Data Model.
▪ Hierarchical Model
▪ Relational Model
▪ Network Database Model
▪ Entity Relationship Model
▪ Object Model
8. What is Relational Algebra?
Relational Algebra, was first created by Edgar F Codd while at IBM. It was used for
modelling the data stored in relational databases and defining queries on it.
III. Additional Five Marks:
1. Explain the components of DBMS.
The Database Management System can be divided into five major components as
follows:
I. Hardware
II. Software
..191..
12 – Computer Science

III. Data
IV. Procedures/Methods
V. Database Access Languages
1. Hardware:
The computer, hard disk, I/O channels for data, and any other physical
component involved in storage of data.
2. Software:
This main component is a program that controls everything. The DBMS
software is capable of understanding the Database Access Languages and
interprets into database commands for execution.
3. Data:
It is the resource for which DBMS is designed. DBMS creation is to store and
utilize data.
4. Procedures/Methods:
They are general instructions to use a database management system such as
installation of DBMS, manage databases to take backups, report generation, etc.
5. DataBase Access Languages:
They are the languages used to write commands to access, insert, update and
delete data stored in any database.
Examples of popular DBMS: Dbase, FoxPro
2. Write about Database Structure.
➢ Table is the entire collection of related data in one table, referred to as a File or
Table where the data is organized as row and column.
➢ Each row in a table represents a record, which is a set of data for each database
entry.
➢ Each table column represents a Field, which groups each piece or item of data
among the records into specific categories or types of data.
Eg. StuNo., StuName, StuAge, StuClass, StuSec.
o A Table is known as a RELATION
o A Row is known as a TUPLE
o A column is known as an ATTRIBUTE

..192..
12. Structured Query Language

I. Additional One Marks:


1. A standard programming language to access and manipulate database is
a) Java b) C c) C++ d) SQL
2. Which of the following allows the user to create, retrieve, alter, and transfer
information among databases?
a) SQL b) Java c) C d) C++
3. The original version of SQL was developed in early
a) 1960’s b) 1970’s c) 1980’s d) 1990’s
4. The latest version of SQL was released in
a) 2002 b) 2004 c) 2006 d) 2008
5. A collection of tables that store sets of data that can be queried for use in other
applications is
a) DBMS b) Data c) Database d) Tables
6. Expand CRUD in RDBMS.
a) Cover, Reuse, Upload, Device b) Create, Read, Update, Delete
c) Creative, Rest, Unload, Download d) None of these
7. A collection of related data entries and it consist of rows and columns is
a) Database b) DBMS c) Tables d) Tuples
8. A horizontal entity in a table which represents the details of a particular entity is
a) Attributes b) Record c) Columns d) Fields
9. Which of the following includes commands to insert, delete, and modify tuples in the
database?
a) DML b) DCL c) DML d) TCL
10. SQL Commands are divided into
a) 7 Categories b) 3 Categories
c) 6 Categories d) 5 Categories
11. SQL Statements used to define the database structure or schema is
a) DDL b) DML c) DCL d) TCL
12. Which of the following provides a set of definitions to specify the storage structure
and access methods used by the database system?
a) DCL b) DML c) DDL d) TCL

..193..
12 – Computer Science

13. To remove all records from a table, also release the space occupied by those records,
we can use,
a) Delete b) Alter c) Drop d) Truncate
14. A computer programming language used for adding, removing and modifying data in
a database is
a) DML b) DCL c) DDL d) DQL
15. Which of the following comprises the SQL-data change statements, which modify
stored data but not the schema of the database table?
a) DQL b) DML c) TCL d) DDL
16. Which of the following cannot be done in DML?
a) Deletion b) Creation c) Modification d) Retrieval
17. How many types of DML are there?
a) 1 b) 2 c) 3 d) 4
18. The command used to delete all records from a table, but not the space occupied by
them is
a) Delete b) Alter c) Drop d) Truncate
19. A programming language used to control the access of data stored in a database is
a) DML b) DCL c) DDL d) DQL
20. Which of the following command withdraws the access permission given by the
GRANT statement?
a) Rollback b) Alter c) Revoke d) Save point
21. The commands used to manage transactions in the database is
a) DQL b) DML c) DCL d) TCL
22. The commands used to query or retrieve data from a database is
a) DQL b) DML c) DCL d) TCL
23. Which of the following is a Data Query Language?
a) Commit b) Create c) Insert d) Select
24. Which of the following is same as integer but the default size may be smaller than
integer?
a) small int b) short int c) dec d) numeric
25. The command used to create a table in SQL is
a) CREATE b) TABLE
c) TABLE CREATE d) CREATE TABLE
..194..

You might also like