Class 11 Computer Science Chapterwise MCQ
Class 11 Computer Science Chapterwise MCQ
Class 11 Computer Science Chapterwise MCQ
CLASS TEST – I
a) yes
b) no
c) machine dependent
a) 31 characters
b) 63 characters
c) 79 characters
a) _a = 1
b) __a = 1
c) __str__ = 1
a) my_string_1
b) 1st_string
c) foo
d) _
Page No 1
5. Why are local variable names beginning with an underscore discouraged?
a) eval
b) assert
c) nonlocal
d) pass
a) lower case
b) UPPER CASE
c) Capitalized
a) unlimited length
c) underscore and ampersand are the only two special characters allowed
a) abc = 1,000,000
Page No 2
d) a_b_c = 1,000,000
a) __init__
b) in
c) it
d) on
Page No 3
CHAPTER 2 - PYTHON FUNDAMENTALS
CLASS TEST – II
Page No 4
a) True
b) False
9. The expression Int(x) implies that the variable x is converted to integer. State
whether true or false.
a) True
b) False
10. Which one of the following have the highest precedence in the expression?
a) Exponential
b) Addition
c) Multiplication
d) Parentheses
Page No 5
SUN VALLEY INTERNATIONAL SCHOOL
2. Given a function that does not return any value, What value is thrown by default
when executed in shell.
a) int
b) bool
c) void
d) None
3. Following set of commands are executed in shell, what will be the output?
>>>str="hello"
>>>str[:2]
>>>
a) he
b) lo
c) olleh
d) hello
a) round(45.8)
b) round(6352.898,2,5)
c) round()
d) round(7463.123,2,1)
Page No 6
5. What is the return type of function id ?
a) int
b) float
c) bool
d) dict
>>>x = 13 ? 2
objective is to make sure x has a integer value, select all that apply (python 3.xx)
a) x = 13 // 2
b) x = int(13 / 2)
c) x = 13 % 2
apple = mango
a) SyntaxError
b) NameError
c) ValueError
d) TypeError
def example(a):
a = a + '2'
a = a*2
return a
>>>example("hello")
Page No 7
a) indentation Error
c) hello2
d) hello2hello2
a) list
b) dictionary
c) array
d) tuple
10. In order to store values in terms of key and value we use what core data type.
a) list
b) tuple
c) class
d) dictionary
c) ‘3\’
d) ”’That’s okay”’
12. What is the average value of the code that is executed below ?
>>>grade1 = 80
>>>grade2 = 90
Page No 8
>>>average = (grade1 + grade2) / 2
a) 85
b) 85.1
c) 95
d) 95.1
hello-how-are-you
c) print(‘hello-‘ + ‘how-are-you’)
a) int
b) bool
c) float
d) None
a) True
b) False
c) Machine dependent
d) Error
a) k = 2 + 3j
b) k = complex(2, 3)
Page No 9
c) k = 2 + 3l
d) k = 2 + 3J
a) Boolean
b) Integer
c) Float
d) Complex
a) -5
b) -4
c) -3
d) +3
a) +5
b) -11
c) +11
d) -5
a) x = 0b101
b) x = 0x4f5
c) x = 19023
d) x = 03964
Page No 10
SUN VALLEY INTERNATIONAL SCHOOL
CLASS TEST IV
x = ['ab', 'cd']
for i in x:
i.upper()
print(x)
a) [‘ab’, ‘cd’].
b) [‘AB’, ‘CD’].
c) [None, None].
x = ['ab', 'cd']
for i in x:
x.append(i.upper())
print(x)
a) [‘AB’, ‘CD’].
c) [‘ab’, ‘cd’].
i=1
while True:
Page No 11
if i%3 == 0:
break
print(i)
i+=1
a) 1 2
b) 1 2 3
c) error
i=1
while True:
if i%0O7 == 0:
break
print(i)
i += 1
a) 1 2 3 4 5 6
b) 1 2 3 4 5 6 7
c) error
i=5
while True:
if i%0O11 == 0:
break
Page No 12
print(i)
i += 1
a) 5 6 7 8 9 10
b) 5 6 7 8
c) 5 6
d) error
i=5
while True:
if i%0O9 == 0:
break
print(i)
i += 1
a) 5 6 7 8
b) 5 6 7 8 9
c) 5 6 7 8 9 10 11 12 13 14 15 ….
d) error
i=1
while True:
if i%2 == 0:
break
print(i)
i += 2
a) 1
b) 1 2
Page No 13
c) 1 2 3 4 5 6 …
d) 1 3 5 7 9 11 …
i=2
while True:
if i%3 == 0:
break
print(i)
i += 2
a) 2 4 6 8 10 …
b) 2 4
c) 2 3
d) error
i=1
while False:
if i%2 == 0:
break
print(i)
i += 2
a) 1
b) 1 3 5 7 …
c) 1 2 3 4 …
Page No 14
10. What is the output of the following?
True = False
while True:
print(True)
break
a) True
b) False
c) None
i=0
while i < 5:
print(i)
i += 1
if i == 3:
break
else:
print(0)
a) 0 1 2 0
b) 0 1 2
c) error
i=0
while i < 3:
print(i)
Page No 15
i += 1
else:
print(0)
a) 0 1 2 3 0
b) 0 1 2 0
c) 0 1 2
d) error
x = "abcdef"
while i in x:
a) a b c d e f
b) abcdef
c) i i i i i i …
d) error
x = "abcdef"
i = "i"
while i in x:
a) no output
b) i i i i i i …
c) a b c d e f
d) abcdef
Page No 16
15. What is the output of the following?
x = 'abcd'
for i in x:
print(i.upper())
a) a b c d
b) A B C D
c) a B C D
d) error
x = 'abcd'
for i in range(len(x)):
i.upper()
print (x)
a) a b c d
b) 0 1 2 3
c) error
x = 'abcd'
for i in range(len(x)):
x = 'a'
print(x)
a) a
Page No 17
b) abcd abcd abcd
c) a a a a
x = 'abcd'
for i in range(len(x)):
print(x)
x = 'a'
a) a
c) a a a a
x = 123
for i in x:
print(i)
a) 1 2 3
b) 123
c) error
for i in d:
print(i)
a) 0 1 2
Page No 18
b) a b c
c) 0 a 1 b 2 c
Answer 1: a
Explanation: The function upper() does not modify a string in place, it returns a new
string which isn’t being stored anywhere
Answer 2: d
Explanation: The loop does not terminate as new elements are being added to the
list in each iteration.
Answer 3: c
Explanation: SyntaxError, there shouldn’t be a space between + and = in +=.
Answer 4: a
Explanation: Control exits the loop when i become
Answer 5: b
Explanation: 0O11 is an octal number.
Answer6: d
Explanation: 9 isn’t allowed in an octal number.
Answer 7: d
Explanation: The loop does not terminate since i is never an even number.
Answer 8: b
Explanation: The numbers 2 and 4 are printed. The next value of i is 6 which is
divisible by 3 and hence control exits the loop
Answer 9: d
Explanation: Control does not enter the loop because of False..
Answer 10 : d
Explanation: SyntaxError, True is a keyword and it’s value cannot be changed.
Answer 11: b
Explanation: The else part is not executed if control breaks out of the loop.
Answer 12: b
Explanation: The else part is executed when the condition in the while statement is
false.
Answer 13: d
Explanation: NameError, i is not defined.
Page No 19
Answer 14: a
Explanation: “i” is not in “abcdef”.
Answer 15: b
Explanation: The instance of the string returned by upper() is being printed.
Answe 16 : c
Explanation: Objects of type int have no attribute upper().
Answer 17: c
Explanation: range() is computed only at the time of entering the loop.
Answer 18 : d
Explanation: abcd a a a is the output as x is modified only after ‘abcd’ has been
printed once.
Answer 19: c
Explanation: Objects of type int are not iterable.
Answer 20: a
Explanation: Loops over the keys of the dictionary.
Page No 20
SUN VALLEY INTERNATIONAL SCHOOL
CHAPTER V
STRING MANIPULATION
CLASS TEST V
>>>"a"+"bc"
a) a
b) bc
c) bca
d) abc
>>>"abcd"[2:]
a) a
b) ab
c) cd
d) dc
a) string.ascii_lowercase_string.digits
b) string.ascii_lowercase+string.ascii_upercase
c) string.letters
d) string.lowercase_string.upercase
Page No 21
4. What is the output when following code is executed ?
>>> str1[-1:]
a) olleh
b) hello
c) h
d) o
a) +
b) *
c) –
>>>print r"\nhello"
The output is
b) \nhello
d) error
>>>print('new' 'line')
a) Error
Page No 22
c) newline
d) new line
>>> print(‘x\97\x98’)
a) Error
b) 97
98
c) x\97
d) \x97\x98
>>>str1="helloworld"
>>>str1[::-1]
a) dlrowolleh
b) hello
c) world
d) helloworld
a) 0xA0xB0xC
b) Error
c) 0x22
d) 33
print("xyyzxyzxzxyy".count('yy'))
a) 2
b) 0
Page No 23
c) error
print("xyyzxyzxzxyy".count('yy', 1))
a) 2
b) 0
c) 1
print("xyyzxyzxzxyy".count('yy', 2))
a) 2
b) 0
c) 1
print("xyyzxyzxzxyy".count('xyy', 0, 100))
a) 2
b) 0
c) 1
d) error
print("xyyzxyzxzxyy".count('xyy', 2, 11))
a) 2
b) 0
c) 1
d) error
Page No 24
print("xyyzxyzxzxyy".count('xyy', -10, -1))
a) 2
b) 0
c) 1
d) error
1 Answer: d
2 Answer: c
3 Answer: b
4 Answer: d
5 Answer: c
6 Answer: b
7 Answer: c
8 Answer: c
9 Answer: a
10 Answer: d
11 Answer: a
12 Answer: a
13 Answer: c
14 Answer: a
15 Answer: b
16 Answer: b
Page No 25
SUN VALLEY INTERNATIONAL SCHOOL
CLASS TEST VI
a) Controlling
b) Tracing
c) Stepping
d) Testing
a) True
b) False
a) GDB
b) GNB
c) FDB
d) FNB
a) he
b) h
c) assist
d) assistant
Page No 26
b) Describes all the commands
a) run
b) exit
c) execute
d) e
7. Which of the following does not affects the execution of the program?
a) Arguments
b) Environment
c) Control
d) I/o
c) no change
a) Identifying
b) Isolating
c) Test
d) Fixing
Page No 27
10. run > outfile command is used to _________
Page No 28
SUN VALLEY INTERNATIONAL SCHOOL
a) Error Free
b) Debug
c) Syntax Error
d) Exception
Page No 29
7. Suppose list1 is [1, 5, 9], what is sum(list1) ?
a) 1
b) 9
c) 15
d) Error
9. Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], which of the following is correct syntax for
slicing operation?
a) print(list1[0])
b) print(list1[:2])
c) print(list1[:-2])
d) all of the mentioned
10. Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1] ?
a) Error
b) None
c) 25
d) 2
11. Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1] ?
a) [2, 33, 222, 14].
b) Error
c) 25
d) [25, 14, 222, 33, 2].
>>>print(names[-1][-1])
a) A
b) Daman
c) Error
d) n
Page No 30
13. What is the output when following code is executed ?
names2 = names1
names3 = names1[:]
names2[0] = 'Alice'
names3[1] = 'Bob'
sum = 0
if ls[0] == 'Alice':
sum += 1
if ls[1] == 'Bob':
sum += 10
print sum
a) 11
b) 12
c) 21
d) 22
a) [2, 6, 4].
b) [1, 3, 2, 1, 3].
c) [1, 3, 2, 1, 3, 2] .
D) [1, 3, 2, 3, 2, 1].
a) [0, 1, 2, 3].
b) [0, 1, 2, 3, 4].
Page No 31
d) [0.0, 0.5, 1.0, 1.5, 2.0].
>>>list2 = [11, 2, 2]
a) True
b) False
c) Error
d) None
a) list1.add(5)
b) list1.append(5)
c) list1.addLast(5)
d) list1.addEnd(5)
a) list1.insert(3, 5)
b) list1.insert(2, 5)
c) list1.add(3, 5)
d) list1.append(3, 5)
a) list1.remove(“hello”)
b) list1.remove(hello)
c) list1.removeAll(“hello”)
d) list1.removeOne(“hello”)
Page No 32
20. Suppose list1 is [3, 4, 5, 20, 5], what is list1.index(5) ?
a) 0
b) 1
c) 4
d) 2
Answers
1 – b 2 – d, 3-a,4-a,5-c,6-d,7-c,8c,9-d,10-c,11-a,12-d,13-b,14-c,15-c,16-b,17-b,18-
a,19-a,20-d
Page No 33
SUN VALLEY INTERNATIONAL SCHOOL
a) [1, 2, 3].
b) (1, 2, 3)
c) {1, 2, 3}
d) {}
a) print(t[3])
b) t[3] = 45
c) print(max(t))
d) print(len(t))
>>>t=(1,2,4,3)
>>>t[1:3]
a) (1, 2)
b) (1, 2, 4)
c) (2, 4)
d) (2, 4, 3)
>>>t=(1,2,4,3)
>>>t[1:-1]
Page No 34
a) (1, 2)
b) (1, 2, 4)
c) (2, 4)
d) (2, 4, 3)
>>>t = (1, 2, 4, 3, 8, 9)
a) [2, 3, 9].
b) [1, 2, 4, 3, 8, 9].
c) [1, 4, 8].
d) (1, 4, 8)
d = {"john":40, "peter":45}
d["john"]
a) 40
b) 45
c) “john”
d) “peter”
>>>t = (1, 2)
>>>2 * t
a) (1, 2, 1, 2)
b) [1, 2, 1, 2].
c) (1, 1, 2, 2)
d) [1, 1, 2, 2].
Page No 35
8. What will be the output?
>>>t1 = (1, 2, 4, 3)
>>>t2 = (1, 2, 3, 4)
>>>t1 < t2
a) True
b) False
c) Error
d) None
>>>my_tuple = (1, 2, 3, 4)
>>>my_tuple.append( (5, 6, 7) )
>>>print len(my_tuple)
a) 1
b) 2
c) 5
d) Error
numberGames = {}
numberGames[(1,2,4)] = 8
numberGames[(4,2,1)] = 10
numberGames[(1,2)] = 12
sum = 0
for k in numberGames:
sum += numberGames[k]
Page No 36
a) 30
b) 24
c) 33
d) 12
a) Tuple
b) Integer
c) List
b) [2,3].
c) (2,3,4)
d) (2,3)
>>> a=(1,2,(4,5))
>>> b=(1,2,(3,4))
>>> a<b
a) False
b) True
d) Error, < operator is valid for tuples but not if there are sub-tuples
14. What is the output of the following piece of code when executed in Python
shell?
>>> a=("Check")*3
Page No 37
>>> a
a) (‘Check’,’Check’,’Check’)
c) (‘CheckCheckCheck’)
d) Syntax error
>>> a=(1,2,3,4)
>>> del(a[2])
a) Now, a=(1,2,4)
b) Now, a=(1,3,4)
c) Now a=(3,4)
>>> a=(2,3,4)
>>> sum(a,3)
c) 12
d) 9
>>> a=(1,2,3,4)
>>> del a
Page No 38
d) No, invalid syntax for del method
a) Array of tuples
b) List of tuples
c) Tuples of lists
d) Invalid type
>>> a=(0,1,2,3,4)
>>> b=slice(0,2)
>>> a[b]
b) [0,2].
c) (0,1)
d) (0,2)
>>> a=(1,2,3)
>>> b=('A','B','C')
>>> c=zip(a,b)
Answers
1 – b 2 – b, 3-c,4-c,5-c,6-a,7-a,8-b,9-d,10-c,11-b,12-d,13-a,14-c,15-d,16-c,17-c,18-
b,19-c,20-a
Page No 39
SUN VALLEY INTERNATIONAL SCHOOL
CHAPTER IX - DICTIONARIES
CLASS TEST IX
a) d = {}
b) d = {“john”:40, “peter”:45}
c) d = {40:”john”, 45:”peter”}
2. Read the code shown below carefully and pick out the keys?
d = {"john":40, "peter":45}
c) 40 and 45
d) d = (40:”john”, 45:”peter”)
d = {"john":40, "peter":45}
"john" in d
a) True
b) False
c) None
d) Error
d1 = {"john":40, "peter":45}
Page No 40
d2 = {"john":466, "peter":45}
d1 == d2
a) True
b) False
c) None
d) Error
d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45}
d1 > d2
a) True
b) False
c) Error
d) None
d = {"john":40, "peter":45}
d["john"]
a) 40
b) 45
c) “john”
d) “peter”
7. Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john” what command
do we use
a) d.delete(“john”:40)
b) d.delete(“john”)
Page No 41
c) del d[“john”].
d) del d(“john”:40)
a) d.size()
b) len(d)
c) size(d)
d) d.len()
d = {"john":40, "peter":45}
print(list(d.keys()))
a) [“john”, “peter”].
b) [“john”:40, “peter”:45].
c) (“john”, “peter”)
d) (“john”:40, “peter”:45)
a) Since “susan” is not a value in the set, Python raises a KeyError exception
c) Since “susan” is not a key in the set, Python raises a KeyError exception
d) Since “susan” is not a key in the set, Python raises a syntax error
Page No 42
d) Dictionaries are mutable
b) dict([[1,”A”],[2,”B”]])
c) {1,”A”,2”B”}
d) {}
a={1:"A",2:"B",3:"C"}
print(i,j,end=" ")
a) 1A2B3C
b) 123
c) ABC
a={1:"A",2:"B",3:"C"}
print(a.get(1,4))
a) 1
b) A
c) 4
a={1:"A",2:"B",3:"C"}
print(a.get(5,4))
Page No 43
a) Error, invalid syntax
b) A
c) 5
d) 4
a={1:"A",2:"B",3:"C"}
print(a.setdefault(3))
b) C
c) {1: 3, 2: 3, 3: 3}
a={1:"A",2:"B",3:"C"}
a.setdefault(4,"D")
print(a)
b) None.
c) Error.
d) [1,3,6,10].
a={1:"A",2:"B",3:"C"}
b={4:"D",5:"E"}
a.update(b)
print(a)
Page No 44
b) Method update() doesn’t exist for dictionaries
a={1:"A",2:"B",3:"C"}
b=a.copy()
b[2]="D"
print(a)
d) “None” is printed
a={1:"A",2:"B",3:"C"}
a.clear()
print(a)
a) None
d) {}
Answers
1 2 3 4 5 6 7 8 9 10 1 1 13 1 15 1 1 18 1 20
1 2 4 6 7 9
D B A B C A C B A C B C A B D B A C B D
Page No 45
SUN VALLEY INTERNATIONAL SCHOOL
CLASS TEST X
a) Insertion sort
b) Selection sort
c) Bubble sort
d) Merge sort
ANSWER: B
a) Merge sort
b) Typical in-place quick sort
c) Heap sort
d) Selection sort
ANSWER: A
a) Selection sort
b) Heap sort
c) Quick sort
d) Merge sort
ANSWER: D
4. If the given input array is sorted or nearly sorted, which of the following
algorithm gives the best performance?
a) Insertion sort
b) Selection sort
c) Quick sort
d) Merge sort
Page No 46
ANSWER: A
5. Which of the following algorithm pays the least attention to the ordering of
the elements in the input list?
a) Insertion sort
b) Selection sort
c) Quick sort
d) None
ANSWER: B
a) Insertion sort
b) Selection sort
c) Heap sort
d) None
ANSWER: B
7. Which of the following algorithms has lowest worst case time complexity?
a) Insertion sort
b) Selection sort
c) Quick sort
d) Heap sort
ANSWER: D
a) Counting sort
b) Radix sort
c) Bucket sort
d) None
ANSWER: B
Page No 47
9. Which of the following sorting algorithm has the running time that is least
dependant on the initial ordering of the input?
a) Insertion sort
b) Quick sort
c) Merge sort
d) Selection sort
ANSWER: D
10. Which of the following algorithm design technique is used in the quick sort
algorithm?
a) Dynamic programming
b) Backtracking
c) Divide-and-conquer
d) Greedy method
ANSWER: C
a) Divide-and-conquer
b) Backtracking
c) Heuristic approach
d) Greedy approach
ANSWER: A
Page No 48
SUN VALLEY INTERNATIONAL SCHOOL
5. Where are data and programme stored when the processor uses them?
Page No 49
8. Which of the following is a storage device?
c. 680 MB d. 680 GB
14. Human beings are referred to as Homosapinens, which device is called Sillico
Sapiens?
a. Monitor b. Hardware
c. Robot d. Computer
Page No 50
15. Which of the following are input devices?
16. 1 Byte =?
19. Data becomes ................ when it is presented in a format that people can
understand and use
Page No 51
SUN VALLEY INTERNATIONAL SCHOOL
a) 1 b) 2 c) 7 d) 8
4 110+110=…………
9. 110100112= ?16
10 25?10= ?2__________
Page No 52
SUN VALLEY INTERNATIONAL SCHOOL
Page No 53
SUN VALLEY INTERNATIONAL SCHOOL
CHAPTER XV
CLASS TEST XV
1. What is translator?
2. List the compilation steps
3. What is Analysis or Front end phase?
4. What is Synthesis or Back end phase?
5. What is Linking?
6. What is Loader?
7. What is interpreter?
8. What is Cloud Computing?
9. What is public cloud?
10. What is private cloud?
Page No 54
SUN VALLEY INTERNATIONAL SCHOOL
Ans: A
Ans: A
Page No 55
5. ‘AS’ clause is used in SQL for
Ans: C
Ans:c
Ans: C
9. An entity set that does not have sufficient attributes to form a primary key is a
Ans: C
Page No 56
SUN VALLEY INTERNATIONAL SCHOOL
Ans: A
Ans: A
Ans: C
Ans: A
Ans: B
Page No 57
(A) dependent on hardware.
Ans: D
Ans: B
Ans: A
Ans: D
Ans: A
Page No 58
SUN VALLEY INTERNATIONAL SCHOOL
Ans: C
Ans: B
Ans: D
Ans: D
5. NULL is
Page No 59
Ans: D
Page No 60
SUN VALLEY INTERNATIONAL SCHOOL
Consider the following tables SCHOOL and ADMIN. Write SQL commands for the
statements (i) to (iv) and give outputs for SQL queries (v) to (viii).
(i) To display TEACHERNAME, PERIODS of all teachers whose periods less than
25.
(ii) To display TEACHERNAME, CODE and DESIGNATION from tables SCHOOL
and ADMIN whose gender is male.
(iii) To display number of teachers in each subject wise.
(iv) To display CODE, TEACHERNAME and SUBJECT of all teachers who have
joined the school after 01/01/1999.
(v) SELECT MAX (EXPERIENCE), SUBJECT FROM SCHOOL GROUP BY
SUBJECT;
(vi) SELECT TEACHERNAME, GENDER FROM SCHOOL, ADMIN WHERE
DESIGNATION = ‘COORDINATOR’ AND SCHOOL.CODE=ADMIN.CODE;
(vii) SELECT DESIGNATION, COUNT (*) FROM ADMIN GROUP BY
DESIGNATION HAVING COUNT (*) <2;
(viii) SELECT COUNT (DISTINCT SUBJECT) FROM SCHOOL;
Page No 61
SUN VALLEY INTERNATIONAL SCHOOL
Page No 62
SUN VALLEY INTERNATIONAL SCHOOL
CLASS TEST XX
Page No 63
SUN VALLEY INTERNATIONAL SCHOOL
Page No 64
SUN VALLEY INTERNATIONAL SCHOOL
2. What is Malware?
3. What is adware?
4. What is Spyware?
5. What is Phishing?
Page No 65
https://www.sanfoundry.com/python-quiz/
Page No 66