0% found this document useful (0 votes)
86 views19 pages

Revisiontour Output

The document contains multiple-choice questions (MCQs) for Class XII Computer Science, covering topics such as data types, functions, and string manipulation in Python. Each test consists of 20 questions with options and the correct answers provided at the end. The tests are designed to assess students' understanding and application of Python programming concepts.

Uploaded by

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

Topics covered

  • List Slicing,
  • List Methods,
  • Tuple Comparison,
  • Tuple Unpacking,
  • List Summation,
  • Tuples,
  • Data Types,
  • List Sorting,
  • Tuple Initialization,
  • Tuple Creation
0% found this document useful (0 votes)
86 views19 pages

Revisiontour Output

The document contains multiple-choice questions (MCQs) for Class XII Computer Science, covering topics such as data types, functions, and string manipulation in Python. Each test consists of 20 questions with options and the correct answers provided at the end. The tests are designed to assess students' understanding and application of Python programming concepts.

Uploaded by

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

Topics covered

  • List Slicing,
  • List Methods,
  • Tuple Comparison,
  • Tuple Unpacking,
  • List Summation,
  • Tuples,
  • Data Types,
  • List Sorting,
  • Tuple Initialization,
  • Tuple Creation

MCQ

CHAPTER - REVISION TOUR


CLASS TEST – I
Class XII Sub : CS (083)
Time: 40 Min Max Marks: 20

1. Which of these in not a core data type?


a) Lists
b) Dictionary
c) Tuples
d) Class
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

4. Which of the following will run without errors?


a) round(45.8)
b) round(6352.898,2,5)
c) round()
d) round(7463.123,2,1)
5. What is the return type of function id ?
a) int
b) float
c) bool
d) dict
6. In python we do not specify types,it is directly interpreted by the compiler, so
consider the following operation to be performed.
>>>x = 13 ? 2
objective is to make sure x has a integer value, select all that apply (python [Link])
a) x = 13 // 2
b) x = int(13 / 2)
c) x = 13 % 2
d) All of the mentioned

7. What error occurs when you execute?


apple = mango
a) SyntaxError
b) NameError
c) ValueError
d) TypeError

Page No 1
8. Carefully observe the code and give the answer.

def example(a):
a = a + '2'
a = a*2
return a
>>>example("hello")
a) indentation Error
b) cannot perform mathematical operation on strings
c) hello2
d) hello2hello2

9. What data type is the object below ?


L = [1, 23, ‘hello’, 1].
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

11. Which of the following results in a SyntaxError ?


a) ‘”Once upon a time…”, she said.’
b) “He said, ‘Yes!'”
c) ‘3\’
d) ”’That’s okay”’

12. What is the average value of the code that is executed below ?

>>>grade1 = 80
>>>grade2 = 90
>>>average = (grade1 + grade2) / 2
a) 85
b) 85.1
c) 95
d) 95.1

13. Select all options that print


hello-how-are-you
a) print(‘hello’, ‘how’, ‘are’, ‘you’)
b) print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)
c) print(‘hello-‘ + ‘how-are-you’)
d) print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)

14. What is the return value of trunc() ?


a) int
b) bool

Page No 2
c) float
d) None

15. What is the output of print 0.1 + 0.2 == 0.3?


a) True
b) False
c) Machine dependent
d) Error

16. Which of the following is not a complex number?


a) k = 2 + 3j
b) k = complex(2, 3)
c) k = 2 + 3l
d) k = 2 + 3J

17. What is the type of inf?


a) Boolean
b) Integer
c) Float
d) Complex

18. What does ~4 evaluate to?


a) -5
b) -4
c) -3
d) +3

19. What does ~~~~~~5 evaluate to?


a) +5
b) -11
c) +11
d) -5

20. Which of the following is incorrect?


a) x = 0b101
b) x = 0x4f5
c) x = 19023
d) x = 03964

Page No 3
MCQ
CHAPTER - REVISION TOUR
CLASS TEST – II
Class XII Sub : CS (083)
Time: 40 Min Max Marks: 20

1. What is the output of the following?


x = ['ab', 'cd']
for i in x:
[Link]()
print(x)
a) [‘ab’, ‘cd’].
b) [‘AB’, ‘CD’].
c) [None, None].
d) none of the mentioned

2. What is the output of the following?


x = ['ab', 'cd']
for i in x:
[Link]([Link]())
print(x)
a) [‘AB’, ‘CD’].
b) [‘ab’, ‘cd’, ‘AB’, ‘CD’].
c) [‘ab’, ‘cd’].
d) none of the mentioned

3. What is the output of the following?


i=1
while True:
if i%3 == 0:
break
print(i)

i+=1
a) 1 2
b) 1 2 3
c) error
d) none of the mentioned

4. What is the output of the following?


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
d) none of the mentioned

Page No 4
5. What is the output of the following?

i=5
while True:
if i%0O11 == 0:
break
print(i)
i += 1
a) 5 6 7 8 9 10
b) 5 6 7 8
c) 5 6
d) error

6. What is the output of the following?


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

7. What is the output of the following?


i=1
while True:
if i%2 == 0:
break
print(i)
i += 2
a) 1
b) 1 2
c) 1 2 3 4 5 6 …
d) 1 3 5 7 9 11 …

8. What is the output of the following?


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

9. What is the output of the following?


i=1

Page No 5
while False:
if i%2 == 0:
break
print(i)
i += 2
a) 1
b) 1 3 5 7 …
c) 1 2 3 4 …
d) none of the mentioned
10. What is the output of the following?
True = False
while True:
print(True)
break
a) True
b) False
c) None
d) none of the mentioned

11. What is the output of the following?


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
d) none of the mentioned
12. What is the output of the following?
i=0
while i < 3:
print(i)
i += 1
else:
print(0)
a) 0 1 2 3 0
b) 0 1 2 0
c) 0 1 2
d) error
13. What is the output of the following?

x = "abcdef"
while i in x:
print(i, end=" ")
a) a b c d e f
b) abcdef
c) i i i i i i …
d) error

Page No 6
14. What is the output of the following?

x = "abcdef"
i = "i"
while i in x:
print(i, end=" ")
a) no output
b) i i i i i i …
c) a b c d e f
d) abcdef

15. What is the output of the following?

x = 'abcd'
for i in x:
print([Link]())
a) a b c d
b) A B C D
c) a B C D
d) error

16. What is the output of the following?


x = 'abcd'
for i in range(len(x)):
[Link]()
print (x)
a) a b c d
b) 0 1 2 3
c) error
d) none of the mentioned

17. What is the output of the following?

x = 'abcd'
for i in range(len(x)):
x = 'a'
print(x)
a) a
b) abcd abcd abcd
c) a a a a
d) none of the mentioned

18. What is the output of the following?


x = 'abcd'
for i in range(len(x)):
print(x)
x = 'a'
a) a
b) abcd abcd abcd abcd
c) a a a a
d) none of the mentioned

Page No 7
19. What is the output of the following?
x = 123
for i in x:
print(i)
a) 1 2 3
b) 123
c) error
d) none of the mentioned

20 . What is the output of the following?


d = {0: 'a', 1: 'b', 2: 'c'}
for i in d:
print(i)
a) 0 1 2
b) a b c
c) 0 a 1 b 2 c
d) none of the mentioned

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.
Answer 14: a
Explanation: “i” is not in “abcdef”.

Page No 8
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 9
MCQ
CHAPTER - REVISION TOUR
CLASS TEST – III
Class XII Sub : CS (083)
Time: 40 Min Max Marks: 20

1. What is the output when following statement is executed ?


>>>"a"+"bc"
a) a
b) bc
c) bca
d) abc

2. What is the output when following statement is executed ?


>>>"abcd"[2:]
a) a
b) ab
c) cd
d) dc

3. The output of executing string.ascii_letters can also be achieved by:


a) string.ascii_lowercase_string.digits
b) string.ascii_lowercase+string.ascii_upercase
c) [Link]
d) string.lowercase_string.upercase

4. What is the output when following code is executed ?


>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]
a) olleh
b) hello
c) h
d) o

5. What arithmetic operators cannot be used with strings ?


a) +
b) *
c) –
d) All of the mentioned

6. What is the output when following code is executed ?


>>>print r"\nhello"
The output is
a) a new line and hello
b) \nhello
c) the letter r and then hello
d) error

7. What is the output when following statement is executed ?

Page No 10
>>>print('new' 'line')
a) Error
b) Output equivalent to print ‘new\nline’
c) newline
d) new line
8. What is the output when following statement is executed ?
>>> print(‘x\97\x98’)
a) Error
b) 97
98
c) x\97
d) \x97\x98

9. What is the output when following code is executed ?


>>>str1="helloworld"
>>>str1[::-1]
a) dlrowolleh
b) hello
c) world
d) helloworld

10. print(0xA + 0xB + 0xC) :


a) 0xA0xB0xC
b) Error
c) 0x22
d) 33
11. What is the output of the following?
print("xyyzxyzxzxyy".count('yy'))
a) 2
b) 0
c) error
d) none of the mentioned

12. What is the output of the following?


print("xyyzxyzxzxyy".count('yy', 1))
a) 2
b) 0
c) 1
d) none of the mentioned
13. What is the output of the following?
print("xyyzxyzxzxyy".count('yy', 2))
a) 2
b) 0
c) 1
d) none of the mentioned
14. What is the output of the following?
print("xyyzxyzxzxyy".count('xyy', 0, 100))
a) 2
b) 0
c) 1
d) error
15. What is the output of the following?

Page No 11
print("xyyzxyzxzxyy".count('xyy', 2, 11))
a) 2
b) 0
c) 1
d) error
16. What is the output of the following?
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 12
MCQ
CHAPTER - REVISION TOUR
CLASS TEST – IV
Class XII Sub : CS (083)
Time: 40 Min Max Marks: 20

1. Process of removing errors called


a) Error Free
b) Debug
c) Syntax Error
d) Exception
2. Which of the following commands will create a list?
a) list1 = list()
b) list1 = [].
c) list1 = list([1, 2, 3])
d) all of the mentioned
3. What is the output when we execute list(“hello”)?
a) [‘h’, ‘e’, ‘l’, ‘l’, ‘o’].
b) [‘hello’].
c) [‘llo’].
d) [‘olleh’].
4. Suppose list Example is [‘h’,’e’,’l’,’l’,’o’], what is len(list Example)?
a) 5
b) 4
c) None
d) Error
5. Suppose list1 is [2445, 133, 12454, 123], what is max(list1) ?
a) 2445
b) 133
c) 12454
d) 123
6. Suppose list1 is [3, 5, 25, 1, 3], what is min(list1) ?
a) 3
b) 5
c) 25
d) 1
7. Suppose list1 is [1, 5, 9], what is sum(list1) ?
a) 1
b) 9
c) 15
d) Error
8. To shuffle the list(say list1) what function do we use ?
a) [Link] ()
b) shuffle(list1)
c) [Link](list1)
d) [Link](list1)

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])

Page No 13
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].

12. What is the output when following code is executed ?


>>>names = ['Amir', 'Bear', 'Charlton', 'Daman']
>>>print(names[-1][-1])
a) A
b) Daman
c) Error
d) n

13. What is the output when following code is executed ?


names1 = ['Amir', 'Bear', 'Charlton', 'Daman']
names2 = names1
names3 = names1[:]
names2[0] = 'Alice'
names3[1] = 'Bob'
sum = 0
for ls in (names1, names2, names3):
if ls[0] == 'Alice':
sum += 1
if ls[1] == 'Bob':
sum += 10
print sum
a) 11
b) 12
c) 21
d) 22

14. Suppose list1 is [1, 3, 2], What is list1 * 2 ?


a) [2, 6, 4].
b) [1, 3, 2, 1, 3].
c) [1, 3, 2, 1, 3, 2] .
D) [1, 3, 2, 3, 2, 1].

15. Suppose list1 = [0.5 * x for x in range(0, 4)], list1 is :


a) [0, 1, 2, 3].
b) [0, 1, 2, 3, 4].
c) [0.0, 0.5, 1.0, 1.5].
d) [0.0, 0.5, 1.0, 1.5, 2.0].

16. What is the output when following code is executed ?

Page No 14
>>>list1 = [11, 2, 23]
>>>list2 = [11, 2, 2]
>>>list1 < list2 is
a) True
b) False
c) Error
d) None

17. To add a new element to a list we use which command ?


a) [Link](5)
b) [Link](5)
c) [Link](5)
d) [Link](5)
18. To insert 5 to the third position in list1, we use which command ?
a) [Link](3, 5)
b) [Link](2, 5)
c) [Link](3, 5)
d) [Link](3, 5)

19. To remove string “hello” from list1, we use which command ?


a) [Link](“hello”)
b) [Link](hello)
c) [Link](“hello”)
d) [Link](“hello”)

20. Suppose list1 is [3, 4, 5, 20, 5], what is [Link](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 15
MCQ
CHAPTER - REVISION TOUR
CLASS TEST –V
Class XII Sub : CS (083)
Time: 40 Min Max Marks: 20

1. Which of the following is a Python tuple?


a) [1, 2, 3].
b) (1, 2, 3)
c) {1, 2, 3}
d) {}

2. Suppose t = (1, 2, 4, 3), which of the following is incorrect?


a) print(t[3])
b) t[3] = 45
c) print(max(t))
d) print(len(t))

3. What will be the output?


>>>t=(1,2,4,3)
>>>t[1:3]
a) (1, 2)
b) (1, 2, 4)
c) (2, 4)
d) (2, 4, 3)

4. What will be the output?


>>>t=(1,2,4,3)
>>>t[1:-1]
a) (1, 2)
b) (1, 2, 4)
c) (2, 4)
d) (2, 4, 3)

5. What will be the output?


>>>t = (1, 2, 4, 3, 8, 9)
>>>[t[i] for i in range(0, len(t), 2)]
a) [2, 3, 9].
b) [1, 2, 4, 3, 8, 9].
c) [1, 4, 8].
d) (1, 4, 8)

6. What will be the output?


d = {"john":40, "peter":45}
d["john"]
a) 40
b) 45
c) “john”
d) “peter”

7. What will be the output?

Page No 16
>>>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].

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

9. What will be the output?


>>>my_tuple = (1, 2, 3, 4)
>>>my_tuple.append( (5, 6, 7) )
>>>print len(my_tuple)
a) 1
b) 2
c) 5
d) Error

10. What will be the output?


numberGames = {}
numberGames[(1,2,4)] = 8
numberGames[(4,2,1)] = 10
numberGames[(1,2)] = 12
sum = 0
for k in numberGames:
sum += numberGames[k]
print len(numberGames) + sum
a) 30
b) 24
c) 33
d) 12
11. What is the data type of (1)?
a) Tuple
b) Integer
c) List
d) Both tuple and integer

12. If a=(1,2,3,4), a[1:-1] is


a) Error, tuple slicing doesn’t exist
b) [2,3].
c) (2,3,4)
d) (2,3)

13. What is the output of the following code?


>>> a=(1,2,(4,5))

Page No 17
>>> b=(1,2,(3,4))
>>> a<b
a) False
b) True
c) Error, < operator is not valid for tuples
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
>>> a
a) (‘Check’,’Check’,’Check’)
b) * Operator not valid for tuples
c) (‘CheckCheckCheck’)
d) Syntax error

15. What is the output of the following code?


>>> 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)
d) Error as tuple is immutable

16. What is the output of the following code?


>>> a=(2,3,4)
>>> sum(a,3)
a) Too many arguments for sum() method
b) The method sum() doesn’t exist for tuples
c) 12
d) 9

17. Is the following piece of code valid?


>>> a=(1,2,3,4)
>>> del a
a) No because tuple is immutable
b) Yes, first element in the tuple is deleted
c) Yes, the entire tuple is deleted
d) No, invalid syntax for del method
18. What type of data is: a=[(1,1),(2,4),(3,9)]?
a) Array of tuples
b) List of tuples
c) Tuples of lists
d) Invalid type

19. What is the output of the following piece of code?


>>> a=(0,1,2,3,4)
>>> b=slice(0,2)
>>> a[b]
a) Invalid syntax for slicing
b) [0,2].
c) (0,1)

Page No 18
d) (0,2)

20. Is the following piece of code valid?


>>> a=(1,2,3)
>>> b=('A','B','C')
>>> c=zip(a,b)
a) Yes, c will be ((1,2,3),(‘A’,’B’,’C’))
b) Yes, c will be ((1,2,3),(‘A’,’B’,’C’))
c) No because tuples are immutable
d) No because the syntax for zip function isn’t valid
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 19

You might also like